On 05.12.2012, at 07:15, Jimmie Houchin <jlhouchin@gmail.com> wrote:
On 12/4/2012 8:48 PM, Igor Stasenko wrote:
On 5 December 2012 03:22, Jimmie Houchin <jlhouchin@gmail.com> wrote:
Hello,
I am working through implementing NativeBoost interface to a C wrapper dll.
I have 8 callback functions to call in this interface. I am subclassing NBFFICallback as stated in the documentation. I am also implementing the fnSpec method based on the code in the header file.
fnSpec
^#( void (NBExternalString rowID, Row rowData))
This is the code in the header:
typedef void (*TABLE_ROW_CALLBACK)(const char *rowID, FXCHandle rowData);
Should I leave the return type as void or should I use NBVoid?
Either will work. As long as NBFFICallout new resolveType: 'void' and NBFFICallout new resolveType: 'NBVoid' returning same object(s).
I do not know C at all. Is the NBExternalString suitable for the const char *rowID? NBExternalString is a coverter which takes a pointer and turns it into ByteString instance.
But you can use just 'String' as a type qualifier, which is alias for NBExternalString:
String class>>asNBExternalType: gen
^ gen resolveType: #NBExternalString
The documentation says you can use it for char*, but I don't know what difference const makes.
The const modifier matters for C compiler that guarantees that no attempts to write at pointer location will be made.. which is of course get lost when you cross language boundaries and therefore doesn't makes sense specifying in function signature.
NBExternalString takes a pointer as input and then creates an instance of ByteString object and copies contents of C string in newly created object. From that perspective it fits well with 'const char *' type, because at language side you never obtain a real pointer to the string, but just a copy with string contents, and even if you will try to modify that string, you will be modifying a copy, but not original.
P.S. if you load NativeBoost-Help package, there is a page describing in detail how type system and type resolution works.
You can read help using NBHelp open
or just open a help browser..
There could be some glitches loading markdown parser (which i had few days ago).. so if it will fail to work, then you can read from sources here: NBHelpOnFFI class>>types / types2 Thanks for the help and information. I wasn't expecting an answer quite so quickly. I can't tell if you sleep? :)
I haven't been able to get the NBHelp to work yet. In a freshly downloaded NBCog-VM and Pharo-2.0.image after installing NB and NBHelp. When I do, NBHelp open. It starts installing but can't get past petitmarkdown.
There's a new thread on the list about the configuration of PetitParser being broken. This is probably what trips up loading the NB help ("ConfigurationOfPetitParser has broken #'common' section"). Cheers, Max
I don't know if it is a momentary SS3 problem or what. I'll try again in the morning after I get some sleep.
Again, thanks.
Jimmie