Good point. I'll do that.
Another question, In C I do this: typedef struct pst_file { pst_desc_tree *d_head } pst_file; pst_desc_tree *d_ptr; //this is another struct d_ptr = pstfile.d_head; How do I make this assignment with ref-struct? On Thursday, August 23, 2012 12:34:26 PM UTC-4, Nathan Rajlich wrote: > > So basically when you're calling "ref.refType(pst_block_recorder)", > pst_block_recorder is still undefined. I ran into this problem with a > struct that libffi uses, and the solution is to progressively create > the struct instance using the "defineProperty()" function. Try > something like this: > > var pst_block_recorder = Struct(); > pst_block_recorder.defineProperty('next', > ref.refType(pst_block_recorder)); > pst_block_recorder.defineProperty('offset', 'int64'); > pst_block_recorder.defineProperty('size', 'size_t'); > pst_block_recorder.defineProperty('readcount', 'int'); > > On Thu, Aug 23, 2012 at 7:53 AM, rhasson <rha...@gmail.com <javascript:>> > wrote: > > Nathan, > > > > I started using node-ffi which works great. I need to create some > structs > > so I'm using ref-struct. Now some of my structs have pointers to > themselves > > like this: > > > > typedef struct pst_block_recorder { > > struct pst_block_recorder *next; > > int64_t offset; > > size_t size; > > int readcount; > > } pst_block_recorder; > > > > I tried to recreate this with ref-struct like this: > > var pst_block_recorder = Struct ({ > > //struct pst_block_recorder *next; > > 'next': ref.refType(pst_block_recorder), > > //int64_t offset; > > 'offset': 'int64', > > //size_t size; > > 'size': 'size_t', > > //int readcount; > > 'readcount': 'int' > > }); > > > > But I get the following error: > > assert.js:102 > > throw new assert.AssertionError({ > > ^ > > AssertionError: could not determine a proper "type" from: undefined > > at Object.coerceType (/home/roy/node_modules/ref/lib/ref.js:389:3) > > at Object.refType (/home/roy/node_modules/ref/lib/ref.js:304:23) > > > > > > I also tried making those struct fields "pointer" types but the C > library > > doesn't seem to populate them correctly. > > > > Any thoughts? > > > > Thanks, > > Roy > > > > -- > > Job Board: http://jobs.nodejs.org/ > > Posting guidelines: > > https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines > > You received this message because you are subscribed to the Google > > Groups "nodejs" group. > > To post to this group, send email to nod...@googlegroups.com<javascript:> > > To unsubscribe from this group, send email to > > nodejs+un...@googlegroups.com <javascript:> > > For more options, visit this group at > > http://groups.google.com/group/nodejs?hl=en?hl=en > -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en