You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In my javascript , i am trying to create a object, set values and then read them back. However unable to do that for int *data and int *size
constref=require('ref');constStructTypeFactory=require('ref-struct');constArrayTypeFactory=require('ref-array');constinttype=ref.types.int;constbooltype=ref.types.bool;constIntArraytype=ArrayTypeFactory(inttype);constinnerStruct=StructTypeFactory({data: IntArraytype,size: IntArraytype,allocatedSize: inttype,numDimensions: inttype,canFreeData: booltype,});constouterStructure=StructTypeFactory();outerStructure.defineProperty('myProp',ref.refType(innerStruct));constinstance=newouterStructure();constmyPropInst=newinnerStruct({data: newIntArraytype([12,34,23,45]),size: newIntArraytype([0,4]),allocatedSize: 16,numDimensions: 1,canFreeData: true,});instance.myProp=myPropInst.ref();console.dir(instance.myProp.deref().allocatedSize);//WORKS fine, return 16console.dir(instance.myProp.deref().numDimensions);//WORKS fine, return 1console.dir(instance.myProp.deref().canFreeData);//WORKS fine, return trueconsole.dir(instance.myProp.deref().data);//Does NOT give back the expected array [12, 34, 23, 45]console.dir(instance.myProp.deref().size);//Does NOT give back the expected array [0, 4]
What am i missing here.
The text was updated successfully, but these errors were encountered:
Hi, I am using
ref
,ref-struct
&ref-array
to emulate following c structureIn my javascript , i am trying to create a object, set values and then read them back. However unable to do that for
int *data
andint *size
What am i missing here.
The text was updated successfully, but these errors were encountered: