NativeBoost: use of array
Hi again ! I'm having trouble to call the function with the following prototype : void propagateTLE(orbit_t orb, double secondSince[], xyz_t * out, size_t
nbEpoch)
with the corresponding NB call: self nbCall: #( void propagateTLE(orbit_t orbit, double * secondSince,
xyz_t * out, size_t nbEpoch) )
The argument *secondSince* is an input and the argument *out* is the output pointer that the function should fill. I have made 2 subclass of NBExternalArray to feed this function, (allmost) namely: *ArrayOfDoubles *and *ArrayOfXYZ*. Should I mention that type *xyz_t* is a struct that I modeled with an *NBExternalStructure*. I face 2 issues: - The type *ArrayOfXYZ* is refused as an *xyz_t** type. However, the *ArrayOfDoubles *is accepted as a *double** type. - If a get rid of the *out* argument to test the array *secondSince*, I get an undefined error (Error durring FFI call: nil). My current solution is to use the adress of my arrays and the following NB call: self nbCall: #( void propagateTLE(orbit_t orbit, NBExternalAddress
secondSince, NBExternalAddress out, size_t nbEpoch) )
But it feels like I'm cheating my way trough, by pretty much avoiding any type check. Any clue as to why the typecheck of NB is refusing to call my function ? Thanks in advance, Thomas.
On Mon, Aug 04, 2014 at 04:45:46PM +0200, Thomas Bany wrote:
self nbCall: #( void propagateTLE(orbit_t orbit, NBExternalAddress
secondSince, NBExternalAddress out, size_t nbEpoch) )
But it feels like I'm cheating my way trough, by pretty much avoiding any type check. Any clue as to why the typecheck of NB is refusing to call my function ?
I'm not sure if this addresses (heh) your issue, but in NBSQLite3, I do what Punqlite does: NBSQLite3FFI class>>initializeTypeMap TypeMap := Dictionary newFromPairs: #( sqlite3 NBExternalObject sqlite3_stmt NBExternalObject sqlite_int64 NBInt64 ) NBSQLite3FFI class>>nbBindingOf: aTypeName ^ TypeMap at: aTypeName ifAbsent: [ super nbBindingOf: aTypeName ] NBSQLite3FFI>>apiOpen: filename via: handle "int sqlite3_open(const char*, sqlite3**)" <primitive: #primitiveNativeCall module: #NativeBoostPlugin error: errorCode> ^ self nbCall: #(int sqlite3_open (String filename, sqlite3* handle)) module: self library "handle" is the out parameter in sqlite3_open(). NBSQLite3 is at http://ss3.gemtalksystems.com/ss/NBSQLite3. Punqlite is on Smalltalk Hub. -- Pierce Ng http://www.samadhiweb.com/blog/
On 4 August 2014 16:45, Thomas Bany <mun.sysdev@gmail.com> wrote:
Hi again !
I'm having trouble to call the function with the following prototype :
void propagateTLE(orbit_t orb, double secondSince[], xyz_t * out, size_t
nbEpoch)
with the corresponding NB call:
self nbCall: #( void propagateTLE(orbit_t orbit, double * secondSince,
xyz_t * out, size_t nbEpoch) )
The argument *secondSince* is an input and the argument *out* is the output pointer that the function should fill. I have made 2 subclass of NBExternalArray to feed this function, (allmost) namely: *ArrayOfDoubles *and *ArrayOfXYZ*. Should I mention that type *xyz_t* is a struct that I modeled with an *NBExternalStructure*.
I face 2 issues:
- The type *ArrayOfXYZ* is refused as an *xyz_t** type. However, the *ArrayOfDoubles *is accepted as a *double** type. - If a get rid of the *out* argument to test the array *secondSince*, I get an undefined error (Error durring FFI call: nil).
My current solution is to use the adress of my arrays and the following NB call:
self nbCall: #( void propagateTLE(orbit_t orbit, NBExternalAddress
secondSince, NBExternalAddress out, size_t nbEpoch) )
if you explicitly specify NBExternalAddress, then it won't accept any other argument than instance of NBExternalAddress.
Also, note there's no marshallers for (sub)instances of NBExternalArray, and thus you cannot pass them directly, but only by passing pointer to its elements using #address method. I.e, if you using 'whatever *', you can pass a pointer to array by: myArray address.
But it feels like I'm cheating my way trough, by pretty much avoiding any type check. Any clue as to why the typecheck of NB is refusing to call my function ?
Thanks in advance,
Thomas.
-- Best regards, Igor Stasenko.
All right ! Tanks again for you answers and kudos for the NB plugin ! I was kinda scared of doing stuff outside of the image but everything went super smooth. 2014-08-05 16:45 GMT+02:00 Igor Stasenko <siguctua@gmail.com>:
On 4 August 2014 16:45, Thomas Bany <mun.sysdev@gmail.com> wrote:
Hi again !
I'm having trouble to call the function with the following prototype :
void propagateTLE(orbit_t orb, double secondSince[], xyz_t * out, size_t
nbEpoch)
with the corresponding NB call:
self nbCall: #( void propagateTLE(orbit_t orbit, double * secondSince,
xyz_t * out, size_t nbEpoch) )
The argument *secondSince* is an input and the argument *out* is the output pointer that the function should fill. I have made 2 subclass of NBExternalArray to feed this function, (allmost) namely: *ArrayOfDoubles *and *ArrayOfXYZ*. Should I mention that type *xyz_t* is a struct that I modeled with an *NBExternalStructure*.
I face 2 issues:
- The type *ArrayOfXYZ* is refused as an *xyz_t** type. However, the *ArrayOfDoubles *is accepted as a *double** type. - If a get rid of the *out* argument to test the array *secondSince*, I get an undefined error (Error durring FFI call: nil).
My current solution is to use the adress of my arrays and the following NB call:
self nbCall: #( void propagateTLE(orbit_t orbit, NBExternalAddress
secondSince, NBExternalAddress out, size_t nbEpoch) )
if you explicitly specify NBExternalAddress, then it won't accept any other argument than instance of NBExternalAddress.
Also, note there's no marshallers for (sub)instances of NBExternalArray, and thus you cannot pass them directly, but only by passing pointer to its elements using #address method.
I.e, if you using 'whatever *', you can pass a pointer to array by: myArray address.
But it feels like I'm cheating my way trough, by pretty much avoiding any type check. Any clue as to why the typecheck of NB is refusing to call my function ?
Thanks in advance,
Thomas.
-- Best regards, Igor Stasenko.
participants (3)
-
Igor Stasenko -
Pierce Ng -
Thomas Bany