[squeak-dev] FFI problem: "could not coerce arguments"

Mariano Martinez Peck marianopeck at gmail.com
Mon Aug 18 18:44:43 UTC 2008


On Mon, May 26, 2008 at 10:44 AM, Mariano Martinez Peck <
marianopeck at gmail.com> wrote:

>
>
> On Mon, May 26, 2008 at 10:36 AM, Bert Freudenberg <bert at freudenbergs.de>
> wrote:
>
>>
>> On 26.05.2008, at 15:21, Mariano Martinez Peck wrote:
>>
>>  "could not coerce arguments"
>>> int odbx_set_option(
>>>    odbx_t* handle,
>>>    unsigned int option,
>>>    void* value )
>>> apiSetOption: handle option: anOption value: aValue
>>>    "int odbx_unbind(odbx_t*)"
>>>    <cdecl: long 'odbx_set_option' (ulong ulong void*) module: 'opendbx' >
>>>    ^self externalCallFailed
>>>
>>> err := OpenDBX apiSetOption: self option:32  value:1.
>>>
>>
>>
>> The first argument appears to be a pointer to a handle object. You
>> probably should not declare that as ulong if you then pass "self" (which I
>> assume is a ExternalStructure subclass). But that depends on how you acquire
>> the handle, and how you represent it in the image.
>>
>
> Yes you are right, sorry. It was not self, but a attribute called handle.
> My mistake.
>
>
>>
>> The argument to void* should be a ByteArray or WordArray, methinks, I'd
>> try "WordArray with: 1" if you want to pass a pointer to the Integer 1.
>>
>> - Bert -
>>
>
> Sounds interesting. I will test it and then I tell you.
>
>

Bert: I test this using WordArray and I work perfect in all the cases the
value was a number. But the type in the function definition is void*. So,
now, I need to send not only a 1 or 0, but a String. In this case, I cannot
do WordArray with: 'aStringValue'  neither ByteArray with: 'aStringValue' .
What can I do in this case? Do you have any idea?

I mean, I need to use the same parametrer void*, sending it a number or a
string.

many thanks,

mariano


> Thanks,
>
> Mariano
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20080818/a23a591c/attachment.htm


More information about the Squeak-dev mailing list