I just had an underwhelming response to my latest adventure into FFI, specifically wrapping the Acces IO USB API. Specifically, very few functions survived from description to actually being compiled. AFAICT, the compiler does not like underscores in method names for external functions.
I'm not even sure how to describe it other than to give an example. This works: dIOWrite8:deviceIndex byteIndex:byteIndex data:data "unsigned long DIO_Write8(unsigned long DeviceIndex, unsigned long ByteIndex, unsigned char Data)" < cdecl: ulong 'DIO_Write8' ( ulong ulong byte ) > ^self invalidCall. This should compile, but it complains about a mismatch in the number of arguments: DIO_Write8:deviceIndex byteIndex:byteIndex data:data "unsigned long DIO_Write8(unsigned long DeviceIndex, unsigned long ByteIndex, unsigned char Data)" < cdecl: ulong 'DIO_Write8' ( ulong ulong byte ) > ^self invalidCall. The less Pharo forces us to change names as given from the outside, the better off we will be. I am using a 1.1 RC2 image, just in case this has been fixed since then?? I really need to build a new image soon. Bill _______________________________________________ Pharo-project mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project |
I can reproduce the problem. I have this method that works:
apiInitialize: handle backend: backend host: host port: port "long odbx_init(odbx_t**, char*, char*, char*)" <cdecl: long 'odbx_init' (ulong* char* char* char*) module: 'opendbx'> ^self externalCallFailed But not this one: apiInitialize: handle backend: backend host: host port: port "long odbx_init(odbx_t**, char*, char*, char*)" <cdecl: long 'odbx_init' (ulong* char* char* char*) module: 'opendbx'> ^self externalCallFailed a_piInitialize: handle backend: backend host: host port: port "long odbx_init(odbx_t**, char*, char*, char*)" <cdecl: long 'odbx_init' (ulong* char* char* char* Matching number of arguments expected ->) module: 'opendbx'> ^self externalCallFailed Please, open a ticket. Maybe Lukas can help us. Cheers Mariano On Sat, Aug 21, 2010 at 9:47 PM, Schwab,Wilhelm K <[hidden email]> wrote: I just had an underwhelming response to my latest adventure into FFI, specifically wrapping the Acces IO USB API. Specifically, very few functions survived from description to actually being compiled. AFAICT, the compiler does not like underscores in method names for external functions. _______________________________________________ Pharo-project mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project |
See 2842.
Thanks for confirming it! Bill ________________________________________ From: [hidden email] [[hidden email]] On Behalf Of Mariano Martinez Peck [[hidden email]] Sent: Sunday, August 22, 2010 5:41 AM To: [hidden email] Subject: Re: [Pharo-project] FFI and underscores in 1.1 (RC2) I can reproduce the problem. I have this method that works: apiInitialize: handle backend: backend host: host port: port "long odbx_init(odbx_t**, char*, char*, char*)" <cdecl: long 'odbx_init' (ulong* char* char* char*) module: 'opendbx'> ^self externalCallFailed But not this one: apiInitialize: handle backend: backend host: host port: port "long odbx_init(odbx_t**, char*, char*, char*)" <cdecl: long 'odbx_init' (ulong* char* char* char*) module: 'opendbx'> ^self externalCallFailed a_piInitialize: handle backend: backend host: host port: port "long odbx_init(odbx_t**, char*, char*, char*)" <cdecl: long 'odbx_init' (ulong* char* char* char* Matching number of arguments expected ->) module: 'opendbx'> ^self externalCallFailed Please, open a ticket. Maybe Lukas can help us. Cheers Mariano On Sat, Aug 21, 2010 at 9:47 PM, Schwab,Wilhelm K <[hidden email]<mailto:[hidden email]>> wrote: I just had an underwhelming response to my latest adventure into FFI, specifically wrapping the Acces IO USB API. Specifically, very few functions survived from description to actually being compiled. AFAICT, the compiler does not like underscores in method names for external functions. I'm not even sure how to describe it other than to give an example. This works: dIOWrite8:deviceIndex byteIndex:byteIndex data:data "unsigned long DIO_Write8(unsigned long DeviceIndex, unsigned long ByteIndex, unsigned char Data)" < cdecl: ulong 'DIO_Write8' ( ulong ulong byte ) > ^self invalidCall. This should compile, but it complains about a mismatch in the number of arguments: DIO_Write8:deviceIndex byteIndex:byteIndex data:data "unsigned long DIO_Write8(unsigned long DeviceIndex, unsigned long ByteIndex, unsigned char Data)" < cdecl: ulong 'DIO_Write8' ( ulong ulong byte ) > ^self invalidCall. The less Pharo forces us to change names as given from the outside, the better off we will be. I am using a 1.1 RC2 image, just in case this has been fixed since then?? I really need to build a new image soon. Bill _______________________________________________ Pharo-project mailing list [hidden email]<mailto:[hidden email]> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project _______________________________________________ Pharo-project mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project |
Repeat after me: the Debugger is your friend.
You just have to write something like Object compile: 'a_piInitialize: handle backend: backend host: host port: port "long odbx_init(odbx_t**, char*, char*, char*)" <cdecl: long ''odbx_init'' (ulong* char* char* char*) module: ''opendbx''> ^self externalCallFailed' in a workspace and select 'debug it' menu item. Since I'm in a good mood, I tell you the result: In Parser>>externalFunctionDeclaration you can see this sentence: (args position = self properties selector numArgs) ifFalse: [ ^self expected: 'Matching number of arguments']. What if you put an underscore in the selector ? #a_piInitialize:backend:host:port: numArgs -> -1 This means this selector is not recognized as a valid selector... So you have to fix String>>numArgs, then you'll be able to compile a selector with underscores. Repeat after me: the Debugger is your friend. Nicolas 2010/8/22 Schwab,Wilhelm K <[hidden email]>: > See 2842. > > Thanks for confirming it! > > Bill > > ________________________________________ > From: [hidden email] [[hidden email]] On Behalf Of Mariano Martinez Peck [[hidden email]] > Sent: Sunday, August 22, 2010 5:41 AM > To: [hidden email] > Subject: Re: [Pharo-project] FFI and underscores in 1.1 (RC2) > > I can reproduce the problem. I have this method that works: > > apiInitialize: handle backend: backend host: host port: port > "long odbx_init(odbx_t**, char*, char*, char*)" > <cdecl: long 'odbx_init' (ulong* char* char* char*) module: 'opendbx'> > ^self externalCallFailed > > But not this one: > > apiInitialize: handle backend: backend host: host port: port > "long odbx_init(odbx_t**, char*, char*, char*)" > <cdecl: long 'odbx_init' (ulong* char* char* char*) module: 'opendbx'> > ^self externalCallFailed > > a_piInitialize: handle backend: backend host: host port: port > "long odbx_init(odbx_t**, char*, char*, char*)" > <cdecl: long 'odbx_init' (ulong* char* char* char* Matching number of arguments expected ->) module: 'opendbx'> > ^self externalCallFailed > > > Please, open a ticket. Maybe Lukas can help us. > > Cheers > > Mariano > > > On Sat, Aug 21, 2010 at 9:47 PM, Schwab,Wilhelm K <[hidden email]<mailto:[hidden email]>> wrote: > I just had an underwhelming response to my latest adventure into FFI, specifically wrapping the Acces IO USB API. Specifically, very few functions survived from description to actually being compiled. AFAICT, the compiler does not like underscores in method names for external functions. > > I'm not even sure how to describe it other than to give an example. This works: > > dIOWrite8:deviceIndex byteIndex:byteIndex data:data > "unsigned long DIO_Write8(unsigned long DeviceIndex, unsigned long ByteIndex, unsigned char Data)" > > < cdecl: ulong 'DIO_Write8' ( ulong ulong byte ) > > ^self invalidCall. > > > This should compile, but it complains about a mismatch in the number of arguments: > > DIO_Write8:deviceIndex byteIndex:byteIndex data:data > "unsigned long DIO_Write8(unsigned long DeviceIndex, unsigned long ByteIndex, unsigned char Data)" > > < cdecl: ulong 'DIO_Write8' ( ulong ulong byte ) > > ^self invalidCall. > > The less Pharo forces us to change names as given from the outside, the better off we will be. I am using a 1.1 RC2 image, just in case this has been fixed since then?? I really need to build a new image soon. > > Bill > > > _______________________________________________ > Pharo-project mailing list > [hidden email]<mailto:[hidden email]> > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project > > > _______________________________________________ > Pharo-project mailing list > [hidden email] > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project > _______________________________________________ Pharo-project mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project |
FYI: I fixed the #numArgs bug in
http://code.google.com/p/pharo/issues/detail?id=2844. Lukas On 22 August 2010 16:37, Nicolas Cellier <[hidden email]> wrote: > Repeat after me: the Debugger is your friend. > You just have to write something like > > Object compile: 'a_piInitialize: handle backend: backend host: host port: port > "long odbx_init(odbx_t**, char*, char*, char*)" > <cdecl: long ''odbx_init'' (ulong* char* char* char*) module: ''opendbx''> > ^self externalCallFailed' > > in a workspace and select 'debug it' menu item. > > Since I'm in a good mood, I tell you the result: > > In Parser>>externalFunctionDeclaration you can see this sentence: > > (args position = self properties selector numArgs) ifFalse: [ > ^self expected: 'Matching number of arguments']. > > What if you put an underscore in the selector ? > > #a_piInitialize:backend:host:port: numArgs -> -1 > > This means this selector is not recognized as a valid selector... > So you have to fix String>>numArgs, then you'll be able to compile a > selector with underscores. > > Repeat after me: the Debugger is your friend. > > Nicolas > > 2010/8/22 Schwab,Wilhelm K <[hidden email]>: >> See 2842. >> >> Thanks for confirming it! >> >> Bill >> >> ________________________________________ >> From: [hidden email] [[hidden email]] On Behalf Of Mariano Martinez Peck [[hidden email]] >> Sent: Sunday, August 22, 2010 5:41 AM >> To: [hidden email] >> Subject: Re: [Pharo-project] FFI and underscores in 1.1 (RC2) >> >> I can reproduce the problem. I have this method that works: >> >> apiInitialize: handle backend: backend host: host port: port >> "long odbx_init(odbx_t**, char*, char*, char*)" >> <cdecl: long 'odbx_init' (ulong* char* char* char*) module: 'opendbx'> >> ^self externalCallFailed >> >> But not this one: >> >> apiInitialize: handle backend: backend host: host port: port >> "long odbx_init(odbx_t**, char*, char*, char*)" >> <cdecl: long 'odbx_init' (ulong* char* char* char*) module: 'opendbx'> >> ^self externalCallFailed >> >> a_piInitialize: handle backend: backend host: host port: port >> "long odbx_init(odbx_t**, char*, char*, char*)" >> <cdecl: long 'odbx_init' (ulong* char* char* char* Matching number of arguments expected ->) module: 'opendbx'> >> ^self externalCallFailed >> >> >> Please, open a ticket. Maybe Lukas can help us. >> >> Cheers >> >> Mariano >> >> >> On Sat, Aug 21, 2010 at 9:47 PM, Schwab,Wilhelm K <[hidden email]<mailto:[hidden email]>> wrote: >> I just had an underwhelming response to my latest adventure into FFI, specifically wrapping the Acces IO USB API. Specifically, very few functions survived from description to actually being compiled. AFAICT, the compiler does not like underscores in method names for external functions. >> >> I'm not even sure how to describe it other than to give an example. This works: >> >> dIOWrite8:deviceIndex byteIndex:byteIndex data:data >> "unsigned long DIO_Write8(unsigned long DeviceIndex, unsigned long ByteIndex, unsigned char Data)" >> >> < cdecl: ulong 'DIO_Write8' ( ulong ulong byte ) > >> ^self invalidCall. >> >> >> This should compile, but it complains about a mismatch in the number of arguments: >> >> DIO_Write8:deviceIndex byteIndex:byteIndex data:data >> "unsigned long DIO_Write8(unsigned long DeviceIndex, unsigned long ByteIndex, unsigned char Data)" >> >> < cdecl: ulong 'DIO_Write8' ( ulong ulong byte ) > >> ^self invalidCall. >> >> The less Pharo forces us to change names as given from the outside, the better off we will be. I am using a 1.1 RC2 image, just in case this has been fixed since then?? I really need to build a new image soon. >> >> Bill >> >> >> _______________________________________________ >> Pharo-project mailing list >> [hidden email]<mailto:[hidden email]> >> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project >> >> >> _______________________________________________ >> Pharo-project mailing list >> [hidden email] >> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project >> > > _______________________________________________ > Pharo-project mailing list > [hidden email] > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project > -- Lukas Renggli www.lukas-renggli.ch _______________________________________________ Pharo-project mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project |
Great, thanks !
2010/8/22 Lukas Renggli <[hidden email]>: > FYI: I fixed the #numArgs bug in > http://code.google.com/p/pharo/issues/detail?id=2844. > > Lukas > > On 22 August 2010 16:37, Nicolas Cellier > <[hidden email]> wrote: >> Repeat after me: the Debugger is your friend. >> You just have to write something like >> >> Object compile: 'a_piInitialize: handle backend: backend host: host port: port >> "long odbx_init(odbx_t**, char*, char*, char*)" >> <cdecl: long ''odbx_init'' (ulong* char* char* char*) module: ''opendbx''> >> ^self externalCallFailed' >> >> in a workspace and select 'debug it' menu item. >> >> Since I'm in a good mood, I tell you the result: >> >> In Parser>>externalFunctionDeclaration you can see this sentence: >> >> (args position = self properties selector numArgs) ifFalse: [ >> ^self expected: 'Matching number of arguments']. >> >> What if you put an underscore in the selector ? >> >> #a_piInitialize:backend:host:port: numArgs -> -1 >> >> This means this selector is not recognized as a valid selector... >> So you have to fix String>>numArgs, then you'll be able to compile a >> selector with underscores. >> >> Repeat after me: the Debugger is your friend. >> >> Nicolas >> >> 2010/8/22 Schwab,Wilhelm K <[hidden email]>: >>> See 2842. >>> >>> Thanks for confirming it! >>> >>> Bill >>> >>> ________________________________________ >>> From: [hidden email] [[hidden email]] On Behalf Of Mariano Martinez Peck [[hidden email]] >>> Sent: Sunday, August 22, 2010 5:41 AM >>> To: [hidden email] >>> Subject: Re: [Pharo-project] FFI and underscores in 1.1 (RC2) >>> >>> I can reproduce the problem. I have this method that works: >>> >>> apiInitialize: handle backend: backend host: host port: port >>> "long odbx_init(odbx_t**, char*, char*, char*)" >>> <cdecl: long 'odbx_init' (ulong* char* char* char*) module: 'opendbx'> >>> ^self externalCallFailed >>> >>> But not this one: >>> >>> apiInitialize: handle backend: backend host: host port: port >>> "long odbx_init(odbx_t**, char*, char*, char*)" >>> <cdecl: long 'odbx_init' (ulong* char* char* char*) module: 'opendbx'> >>> ^self externalCallFailed >>> >>> a_piInitialize: handle backend: backend host: host port: port >>> "long odbx_init(odbx_t**, char*, char*, char*)" >>> <cdecl: long 'odbx_init' (ulong* char* char* char* Matching number of arguments expected ->) module: 'opendbx'> >>> ^self externalCallFailed >>> >>> >>> Please, open a ticket. Maybe Lukas can help us. >>> >>> Cheers >>> >>> Mariano >>> >>> >>> On Sat, Aug 21, 2010 at 9:47 PM, Schwab,Wilhelm K <[hidden email]<mailto:[hidden email]>> wrote: >>> I just had an underwhelming response to my latest adventure into FFI, specifically wrapping the Acces IO USB API. Specifically, very few functions survived from description to actually being compiled. AFAICT, the compiler does not like underscores in method names for external functions. >>> >>> I'm not even sure how to describe it other than to give an example. This works: >>> >>> dIOWrite8:deviceIndex byteIndex:byteIndex data:data >>> "unsigned long DIO_Write8(unsigned long DeviceIndex, unsigned long ByteIndex, unsigned char Data)" >>> >>> < cdecl: ulong 'DIO_Write8' ( ulong ulong byte ) > >>> ^self invalidCall. >>> >>> >>> This should compile, but it complains about a mismatch in the number of arguments: >>> >>> DIO_Write8:deviceIndex byteIndex:byteIndex data:data >>> "unsigned long DIO_Write8(unsigned long DeviceIndex, unsigned long ByteIndex, unsigned char Data)" >>> >>> < cdecl: ulong 'DIO_Write8' ( ulong ulong byte ) > >>> ^self invalidCall. >>> >>> The less Pharo forces us to change names as given from the outside, the better off we will be. I am using a 1.1 RC2 image, just in case this has been fixed since then?? I really need to build a new image soon. >>> >>> Bill >>> >>> >>> _______________________________________________ >>> Pharo-project mailing list >>> [hidden email]<mailto:[hidden email]> >>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project >>> >>> >>> _______________________________________________ >>> Pharo-project mailing list >>> [hidden email] >>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project >>> >> >> _______________________________________________ >> Pharo-project mailing list >> [hidden email] >> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project >> > > > > -- > Lukas Renggli > www.lukas-renggli.ch > > _______________________________________________ > Pharo-project mailing list > [hidden email] > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project > _______________________________________________ Pharo-project mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project |
In reply to this post by Nicolas Cellier
On Aug 22, 2010, at 4:37 PM, Nicolas Cellier wrote: > Repeat after me: the Debugger is your friend. > You just have to write something like the Debugger is your friend :D This is always one of the pattern that oscar identifies in Smalltalk programming. > > Object compile: 'a_piInitialize: handle backend: backend host: host port: port > "long odbx_init(odbx_t**, char*, char*, char*)" > <cdecl: long ''odbx_init'' (ulong* char* char* char*) module: ''opendbx''> > ^self externalCallFailed' > > in a workspace and select 'debug it' menu item. > > Since I'm in a good mood, I tell you the result: > > In Parser>>externalFunctionDeclaration you can see this sentence: > > (args position = self properties selector numArgs) ifFalse: [ > ^self expected: 'Matching number of arguments']. > > What if you put an underscore in the selector ? > > #a_piInitialize:backend:host:port: numArgs -> -1 > > This means this selector is not recognized as a valid selector... > So you have to fix String>>numArgs, then you'll be able to compile a > selector with underscores. > > Repeat after me: the Debugger is your friend. > > Nicolas > > 2010/8/22 Schwab,Wilhelm K <[hidden email]>: >> See 2842. >> >> Thanks for confirming it! >> >> Bill >> >> ________________________________________ >> From: [hidden email] [[hidden email]] On Behalf Of Mariano Martinez Peck [[hidden email]] >> Sent: Sunday, August 22, 2010 5:41 AM >> To: [hidden email] >> Subject: Re: [Pharo-project] FFI and underscores in 1.1 (RC2) >> >> I can reproduce the problem. I have this method that works: >> >> apiInitialize: handle backend: backend host: host port: port >> "long odbx_init(odbx_t**, char*, char*, char*)" >> <cdecl: long 'odbx_init' (ulong* char* char* char*) module: 'opendbx'> >> ^self externalCallFailed >> >> But not this one: >> >> apiInitialize: handle backend: backend host: host port: port >> "long odbx_init(odbx_t**, char*, char*, char*)" >> <cdecl: long 'odbx_init' (ulong* char* char* char*) module: 'opendbx'> >> ^self externalCallFailed >> >> a_piInitialize: handle backend: backend host: host port: port >> "long odbx_init(odbx_t**, char*, char*, char*)" >> <cdecl: long 'odbx_init' (ulong* char* char* char* Matching number of arguments expected ->) module: 'opendbx'> >> ^self externalCallFailed >> >> >> Please, open a ticket. Maybe Lukas can help us. >> >> Cheers >> >> Mariano >> >> >> On Sat, Aug 21, 2010 at 9:47 PM, Schwab,Wilhelm K <[hidden email]<mailto:[hidden email]>> wrote: >> I just had an underwhelming response to my latest adventure into FFI, specifically wrapping the Acces IO USB API. Specifically, very few functions survived from description to actually being compiled. AFAICT, the compiler does not like underscores in method names for external functions. >> >> I'm not even sure how to describe it other than to give an example. This works: >> >> dIOWrite8:deviceIndex byteIndex:byteIndex data:data >> "unsigned long DIO_Write8(unsigned long DeviceIndex, unsigned long ByteIndex, unsigned char Data)" >> >> < cdecl: ulong 'DIO_Write8' ( ulong ulong byte ) > >> ^self invalidCall. >> >> >> This should compile, but it complains about a mismatch in the number of arguments: >> >> DIO_Write8:deviceIndex byteIndex:byteIndex data:data >> "unsigned long DIO_Write8(unsigned long DeviceIndex, unsigned long ByteIndex, unsigned char Data)" >> >> < cdecl: ulong 'DIO_Write8' ( ulong ulong byte ) > >> ^self invalidCall. >> >> The less Pharo forces us to change names as given from the outside, the better off we will be. I am using a 1.1 RC2 image, just in case this has been fixed since then?? I really need to build a new image soon. >> >> Bill >> >> >> _______________________________________________ >> Pharo-project mailing list >> [hidden email]<mailto:[hidden email]> >> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project >> >> >> _______________________________________________ >> Pharo-project mailing list >> [hidden email] >> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project >> > > _______________________________________________ > Pharo-project mailing list > [hidden email] > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project _______________________________________________ Pharo-project mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project |
In reply to this post by Lukas Renggli
***thanks*** lukas!
I love that spirit and atmosphere! This makes integrating far less boring. Stef On Aug 22, 2010, at 5:46 PM, Lukas Renggli wrote: > FYI: I fixed the #numArgs bug in > http://code.google.com/p/pharo/issues/detail?id=2844. > > Lukas > > On 22 August 2010 16:37, Nicolas Cellier > <[hidden email]> wrote: >> Repeat after me: the Debugger is your friend. >> You just have to write something like >> >> Object compile: 'a_piInitialize: handle backend: backend host: host port: port >> "long odbx_init(odbx_t**, char*, char*, char*)" >> <cdecl: long ''odbx_init'' (ulong* char* char* char*) module: ''opendbx''> >> ^self externalCallFailed' >> >> in a workspace and select 'debug it' menu item. >> >> Since I'm in a good mood, I tell you the result: >> >> In Parser>>externalFunctionDeclaration you can see this sentence: >> >> (args position = self properties selector numArgs) ifFalse: [ >> ^self expected: 'Matching number of arguments']. >> >> What if you put an underscore in the selector ? >> >> #a_piInitialize:backend:host:port: numArgs -> -1 >> >> This means this selector is not recognized as a valid selector... >> So you have to fix String>>numArgs, then you'll be able to compile a >> selector with underscores. >> >> Repeat after me: the Debugger is your friend. >> >> Nicolas >> >> 2010/8/22 Schwab,Wilhelm K <[hidden email]>: >>> See 2842. >>> >>> Thanks for confirming it! >>> >>> Bill >>> >>> ________________________________________ >>> From: [hidden email] [[hidden email]] On Behalf Of Mariano Martinez Peck [[hidden email]] >>> Sent: Sunday, August 22, 2010 5:41 AM >>> To: [hidden email] >>> Subject: Re: [Pharo-project] FFI and underscores in 1.1 (RC2) >>> >>> I can reproduce the problem. I have this method that works: >>> >>> apiInitialize: handle backend: backend host: host port: port >>> "long odbx_init(odbx_t**, char*, char*, char*)" >>> <cdecl: long 'odbx_init' (ulong* char* char* char*) module: 'opendbx'> >>> ^self externalCallFailed >>> >>> But not this one: >>> >>> apiInitialize: handle backend: backend host: host port: port >>> "long odbx_init(odbx_t**, char*, char*, char*)" >>> <cdecl: long 'odbx_init' (ulong* char* char* char*) module: 'opendbx'> >>> ^self externalCallFailed >>> >>> a_piInitialize: handle backend: backend host: host port: port >>> "long odbx_init(odbx_t**, char*, char*, char*)" >>> <cdecl: long 'odbx_init' (ulong* char* char* char* Matching number of arguments expected ->) module: 'opendbx'> >>> ^self externalCallFailed >>> >>> >>> Please, open a ticket. Maybe Lukas can help us. >>> >>> Cheers >>> >>> Mariano >>> >>> >>> On Sat, Aug 21, 2010 at 9:47 PM, Schwab,Wilhelm K <[hidden email]<mailto:[hidden email]>> wrote: >>> I just had an underwhelming response to my latest adventure into FFI, specifically wrapping the Acces IO USB API. Specifically, very few functions survived from description to actually being compiled. AFAICT, the compiler does not like underscores in method names for external functions. >>> >>> I'm not even sure how to describe it other than to give an example. This works: >>> >>> dIOWrite8:deviceIndex byteIndex:byteIndex data:data >>> "unsigned long DIO_Write8(unsigned long DeviceIndex, unsigned long ByteIndex, unsigned char Data)" >>> >>> < cdecl: ulong 'DIO_Write8' ( ulong ulong byte ) > >>> ^self invalidCall. >>> >>> >>> This should compile, but it complains about a mismatch in the number of arguments: >>> >>> DIO_Write8:deviceIndex byteIndex:byteIndex data:data >>> "unsigned long DIO_Write8(unsigned long DeviceIndex, unsigned long ByteIndex, unsigned char Data)" >>> >>> < cdecl: ulong 'DIO_Write8' ( ulong ulong byte ) > >>> ^self invalidCall. >>> >>> The less Pharo forces us to change names as given from the outside, the better off we will be. I am using a 1.1 RC2 image, just in case this has been fixed since then?? I really need to build a new image soon. >>> >>> Bill >>> >>> >>> _______________________________________________ >>> Pharo-project mailing list >>> [hidden email]<mailto:[hidden email]> >>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project >>> >>> >>> _______________________________________________ >>> Pharo-project mailing list >>> [hidden email] >>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project >>> >> >> _______________________________________________ >> Pharo-project mailing list >> [hidden email] >> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project >> > > > > -- > Lukas Renggli > www.lukas-renggli.ch > > _______________________________________________ > Pharo-project mailing list > [hidden email] > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project _______________________________________________ Pharo-project mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project |
In reply to this post by Lukas Renggli
We will include it with a couple of 1.1.1 bug fixes.
Stef On Aug 22, 2010, at 5:46 PM, Lukas Renggli wrote: > FYI: I fixed the #numArgs bug in > http://code.google.com/p/pharo/issues/detail?id=2844. > > Lukas > > On 22 August 2010 16:37, Nicolas Cellier > <[hidden email]> wrote: >> Repeat after me: the Debugger is your friend. >> You just have to write something like >> >> Object compile: 'a_piInitialize: handle backend: backend host: host port: port >> "long odbx_init(odbx_t**, char*, char*, char*)" >> <cdecl: long ''odbx_init'' (ulong* char* char* char*) module: ''opendbx''> >> ^self externalCallFailed' >> >> in a workspace and select 'debug it' menu item. >> >> Since I'm in a good mood, I tell you the result: >> >> In Parser>>externalFunctionDeclaration you can see this sentence: >> >> (args position = self properties selector numArgs) ifFalse: [ >> ^self expected: 'Matching number of arguments']. >> >> What if you put an underscore in the selector ? >> >> #a_piInitialize:backend:host:port: numArgs -> -1 >> >> This means this selector is not recognized as a valid selector... >> So you have to fix String>>numArgs, then you'll be able to compile a >> selector with underscores. >> >> Repeat after me: the Debugger is your friend. >> >> Nicolas >> >> 2010/8/22 Schwab,Wilhelm K <[hidden email]>: >>> See 2842. >>> >>> Thanks for confirming it! >>> >>> Bill >>> >>> ________________________________________ >>> From: [hidden email] [[hidden email]] On Behalf Of Mariano Martinez Peck [[hidden email]] >>> Sent: Sunday, August 22, 2010 5:41 AM >>> To: [hidden email] >>> Subject: Re: [Pharo-project] FFI and underscores in 1.1 (RC2) >>> >>> I can reproduce the problem. I have this method that works: >>> >>> apiInitialize: handle backend: backend host: host port: port >>> "long odbx_init(odbx_t**, char*, char*, char*)" >>> <cdecl: long 'odbx_init' (ulong* char* char* char*) module: 'opendbx'> >>> ^self externalCallFailed >>> >>> But not this one: >>> >>> apiInitialize: handle backend: backend host: host port: port >>> "long odbx_init(odbx_t**, char*, char*, char*)" >>> <cdecl: long 'odbx_init' (ulong* char* char* char*) module: 'opendbx'> >>> ^self externalCallFailed >>> >>> a_piInitialize: handle backend: backend host: host port: port >>> "long odbx_init(odbx_t**, char*, char*, char*)" >>> <cdecl: long 'odbx_init' (ulong* char* char* char* Matching number of arguments expected ->) module: 'opendbx'> >>> ^self externalCallFailed >>> >>> >>> Please, open a ticket. Maybe Lukas can help us. >>> >>> Cheers >>> >>> Mariano >>> >>> >>> On Sat, Aug 21, 2010 at 9:47 PM, Schwab,Wilhelm K <[hidden email]<mailto:[hidden email]>> wrote: >>> I just had an underwhelming response to my latest adventure into FFI, specifically wrapping the Acces IO USB API. Specifically, very few functions survived from description to actually being compiled. AFAICT, the compiler does not like underscores in method names for external functions. >>> >>> I'm not even sure how to describe it other than to give an example. This works: >>> >>> dIOWrite8:deviceIndex byteIndex:byteIndex data:data >>> "unsigned long DIO_Write8(unsigned long DeviceIndex, unsigned long ByteIndex, unsigned char Data)" >>> >>> < cdecl: ulong 'DIO_Write8' ( ulong ulong byte ) > >>> ^self invalidCall. >>> >>> >>> This should compile, but it complains about a mismatch in the number of arguments: >>> >>> DIO_Write8:deviceIndex byteIndex:byteIndex data:data >>> "unsigned long DIO_Write8(unsigned long DeviceIndex, unsigned long ByteIndex, unsigned char Data)" >>> >>> < cdecl: ulong 'DIO_Write8' ( ulong ulong byte ) > >>> ^self invalidCall. >>> >>> The less Pharo forces us to change names as given from the outside, the better off we will be. I am using a 1.1 RC2 image, just in case this has been fixed since then?? I really need to build a new image soon. >>> >>> Bill >>> >>> >>> _______________________________________________ >>> Pharo-project mailing list >>> [hidden email]<mailto:[hidden email]> >>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project >>> >>> >>> _______________________________________________ >>> Pharo-project mailing list >>> [hidden email] >>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project >>> >> >> _______________________________________________ >> Pharo-project mailing list >> [hidden email] >> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project >> > > > > -- > Lukas Renggli > www.lukas-renggli.ch > > _______________________________________________ > Pharo-project mailing list > [hidden email] > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project _______________________________________________ Pharo-project mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project |
Free forum by Nabble | Edit this page |