UFFI can not generate Structure accessor of type char[100]
I have FFIExternalStructure which has at class side fieldsDesc ^#( char data[100]; int count; ) if I try to do EphCPPTestStructure rebuildFieldAccessors . in order to generate the accessors for the members of the struct it complains with an error that it does not recognise the type of " [ " Does that mean that char arrays are other arrays are not supported as struct members or will I have to do this manually ?
it never could. you need to do a âspecial typeâ, who has to be something like: YourStruct class>>initialize Char100 := FFITypeArray ofType: #char. fieldsDesc ^ #( Char100 data; int count; ) but then⦠you want to optimise that and in field accessors, who will look something like this: YourStruct >>data "This method was automatically generated" ^(FFITypeArray ofType: #char size: 100) fromHandle: (handle copyFrom: 1 to: 100) you can change that for: YourStruct >>data "This method was automatically generated" ^Char100 fromHandle: (handle copyFrom: 1 to: 100) and same for setter. (other way will work, but it will be suboptimal) Esteban
On 8 Nov 2016, at 12:10, Dimitris Chloupis <kilon.alios@gmail.com> wrote:
I have FFIExternalStructure which has at class side
fieldsDesc ^#( char data[100]; int count; )
if I try to do
EphCPPTestStructure rebuildFieldAccessors .
in order to generate the accessors for the members of the struct it complains with an error that it does not recognise the type of " [ "
Does that mean that char arrays are other arrays are not supported as struct members or will I have to do this manually ?
I was reaching a similar conclusion Currently I have a void pointer to the struct with the members I mentioned I can get char[100] pointerToStruct fromCString and I can get the int with pointerToStruct getHandle integerAt: 101 size:4 signed: false so if I want to pass the address of the pointer to my YourStruct instance will I have to initialize with YourStruct fromHandler: (pointerToStruct getHandle) is this a correct and safe way to pass the address ? On Tue, Nov 8, 2016 at 1:21 PM Esteban Lorenzano <estebanlm@gmail.com> wrote:
it never could. you need to do a âspecial typeâ, who has to be something like:
YourStruct class>>initialize Char100 := FFITypeArray ofType: #char.
fieldsDesc ^ #( Char100 data; int count; )
but then⦠you want to optimise that and in field accessors, who will look something like this:
YourStruct >>data "This method was automatically generated" ^(FFITypeArray ofType: #char size: 100) fromHandle: (handle copyFrom: 1 to: 100)
you can change that for:
YourStruct >>data "This method was automatically generated" ^Char100 fromHandle: (handle copyFrom: 1 to: 100)
and same for setter. (other way will work, but it will be suboptimal)
Esteban
On 8 Nov 2016, at 12:10, Dimitris Chloupis <kilon.alios@gmail.com> wrote:
I have FFIExternalStructure which has at class side
fieldsDesc ^#( char data[100]; int count; )
if I try to do
EphCPPTestStructure rebuildFieldAccessors .
in order to generate the accessors for the members of the struct it complains with an error that it does not recognise the type of " [ "
Does that mean that char arrays are other arrays are not supported as struct members or will I have to do this manually ?
On 8 Nov 2016, at 12:49, Dimitris Chloupis <kilon.alios@gmail.com> wrote:
I was reaching a similar conclusion
Currently I have a void pointer to the struct with the members I mentioned
I can get char[100]
pointerToStruct fromCString
and I can get the int with
pointerToStruct getHandle integerAt: 101 size:4 signed: false
so if I want to pass the address of the pointer to my YourStruct instance will I have to initialize with
YourStruct fromHandler: (pointerToStruct getHandle)
is this a correct and safe way to pass the address ?
yes. Esteban
On Tue, Nov 8, 2016 at 1:21 PM Esteban Lorenzano <estebanlm@gmail.com <mailto:estebanlm@gmail.com>> wrote: it never could. you need to do a âspecial typeâ, who has to be something like:
YourStruct class>>initialize Char100 := FFITypeArray ofType: #char.
fieldsDesc ^ #( Char100 data; int count; )
but then⦠you want to optimise that and in field accessors, who will look something like this:
YourStruct >>data "This method was automatically generated" ^(FFITypeArray ofType: #char size: 100) fromHandle: (handle copyFrom: 1 to: 100)
you can change that for:
YourStruct >>data "This method was automatically generated" ^Char100 fromHandle: (handle copyFrom: 1 to: 100)
and same for setter. (other way will work, but it will be suboptimal)
Esteban
On 8 Nov 2016, at 12:10, Dimitris Chloupis <kilon.alios@gmail.com <mailto:kilon.alios@gmail.com>> wrote:
I have FFIExternalStructure which has at class side
fieldsDesc ^#( char data[100]; int count; )
if I try to do
EphCPPTestStructure rebuildFieldAccessors .
in order to generate the accessors for the members of the struct it complains with an error that it does not recognise the type of " [ "
Does that mean that char arrays are other arrays are not supported as struct members or will I have to do this manually ?
Thank you Esteban By the way I really love the design of UFFI , very clean and quite easy to understand , great work to you and Igor :) On Tue, Nov 8, 2016 at 1:54 PM Esteban Lorenzano <estebanlm@gmail.com> wrote:
On 8 Nov 2016, at 12:49, Dimitris Chloupis <kilon.alios@gmail.com> wrote:
I was reaching a similar conclusion
Currently I have a void pointer to the struct with the members I mentioned
I can get char[100]
pointerToStruct fromCString
and I can get the int with
pointerToStruct getHandle integerAt: 101 size:4 signed: false
so if I want to pass the address of the pointer to my YourStruct instance will I have to initialize with
YourStruct fromHandler: (pointerToStruct getHandle)
is this a correct and safe way to pass the address ?
yes.
Esteban
On Tue, Nov 8, 2016 at 1:21 PM Esteban Lorenzano <estebanlm@gmail.com> wrote:
it never could. you need to do a âspecial typeâ, who has to be something like:
YourStruct class>>initialize Char100 := FFITypeArray ofType: #char.
fieldsDesc ^ #( Char100 data; int count; )
but then⦠you want to optimise that and in field accessors, who will look something like this:
YourStruct >>data "This method was automatically generated" ^(FFITypeArray ofType: #char size: 100) fromHandle: (handle copyFrom: 1 to: 100)
you can change that for:
YourStruct >>data "This method was automatically generated" ^Char100 fromHandle: (handle copyFrom: 1 to: 100)
and same for setter. (other way will work, but it will be suboptimal)
Esteban
On 8 Nov 2016, at 12:10, Dimitris Chloupis <kilon.alios@gmail.com> wrote:
I have FFIExternalStructure which has at class side
fieldsDesc ^#( char data[100]; int count; )
if I try to do
EphCPPTestStructure rebuildFieldAccessors .
in order to generate the accessors for the members of the struct it complains with an error that it does not recognise the type of " [ "
Does that mean that char arrays are other arrays are not supported as struct members or will I have to do this manually ?
On 8 Nov 2016, at 12:55, Dimitris Chloupis <kilon.alios@gmail.com> wrote:
Thank you Esteban
By the way I really love the design of UFFI , very clean and quite easy to understand , great work to you and Igor :)
UFFI is just mine ;) (but I sanded in giant shoulders as I took Igor work as inspiration⦠and to âborrowâ many cool ideas) Esteban
On Tue, Nov 8, 2016 at 1:54 PM Esteban Lorenzano <estebanlm@gmail.com <mailto:estebanlm@gmail.com>> wrote:
On 8 Nov 2016, at 12:49, Dimitris Chloupis <kilon.alios@gmail.com <mailto:kilon.alios@gmail.com>> wrote:
I was reaching a similar conclusion
Currently I have a void pointer to the struct with the members I mentioned
I can get char[100]
pointerToStruct fromCString
and I can get the int with
pointerToStruct getHandle integerAt: 101 size:4 signed: false
so if I want to pass the address of the pointer to my YourStruct instance will I have to initialize with
YourStruct fromHandler: (pointerToStruct getHandle)
is this a correct and safe way to pass the address ?
yes.
Esteban
On Tue, Nov 8, 2016 at 1:21 PM Esteban Lorenzano <estebanlm@gmail.com <mailto:estebanlm@gmail.com>> wrote: it never could. you need to do a âspecial typeâ, who has to be something like:
YourStruct class>>initialize Char100 := FFITypeArray ofType: #char.
fieldsDesc ^ #( Char100 data; int count; )
but then⦠you want to optimise that and in field accessors, who will look something like this:
YourStruct >>data "This method was automatically generated" ^(FFITypeArray ofType: #char size: 100) fromHandle: (handle copyFrom: 1 to: 100)
you can change that for:
YourStruct >>data "This method was automatically generated" ^Char100 fromHandle: (handle copyFrom: 1 to: 100)
and same for setter. (other way will work, but it will be suboptimal)
Esteban
On 8 Nov 2016, at 12:10, Dimitris Chloupis <kilon.alios@gmail.com <mailto:kilon.alios@gmail.com>> wrote:
I have FFIExternalStructure which has at class side
fieldsDesc ^#( char data[100]; int count; )
if I try to do
EphCPPTestStructure rebuildFieldAccessors .
in order to generate the accessors for the members of the struct it complains with an error that it does not recognise the type of " [ "
Does that mean that char arrays are other arrays are not supported as struct members or will I have to do this manually ?
then great work^2 Do you want me to add this information to the UFFI documentation ? Probably I will also add some more examples for handles, pointers etc. I assume this is the repo for the docs of UFFI https://github.com/SquareBracketAssociates/PharoInProgress correct ? On Tue, Nov 8, 2016 at 2:12 PM Esteban Lorenzano <estebanlm@gmail.com> wrote:
On 8 Nov 2016, at 12:55, Dimitris Chloupis <kilon.alios@gmail.com> wrote:
Thank you Esteban
By the way I really love the design of UFFI , very clean and quite easy to understand , great work to you and Igor :)
UFFI is just mine ;) (but I sanded in giant shoulders as I took Igor work as inspiration⦠and to âborrowâ many cool ideas)
Esteban
On Tue, Nov 8, 2016 at 1:54 PM Esteban Lorenzano <estebanlm@gmail.com> wrote:
On 8 Nov 2016, at 12:49, Dimitris Chloupis <kilon.alios@gmail.com> wrote:
I was reaching a similar conclusion
Currently I have a void pointer to the struct with the members I mentioned
I can get char[100]
pointerToStruct fromCString
and I can get the int with
pointerToStruct getHandle integerAt: 101 size:4 signed: false
so if I want to pass the address of the pointer to my YourStruct instance will I have to initialize with
YourStruct fromHandler: (pointerToStruct getHandle)
is this a correct and safe way to pass the address ?
yes.
Esteban
On Tue, Nov 8, 2016 at 1:21 PM Esteban Lorenzano <estebanlm@gmail.com> wrote:
it never could. you need to do a âspecial typeâ, who has to be something like:
YourStruct class>>initialize Char100 := FFITypeArray ofType: #char.
fieldsDesc ^ #( Char100 data; int count; )
but then⦠you want to optimise that and in field accessors, who will look something like this:
YourStruct >>data "This method was automatically generated" ^(FFITypeArray ofType: #char size: 100) fromHandle: (handle copyFrom: 1 to: 100)
you can change that for:
YourStruct >>data "This method was automatically generated" ^Char100 fromHandle: (handle copyFrom: 1 to: 100)
and same for setter. (other way will work, but it will be suboptimal)
Esteban
On 8 Nov 2016, at 12:10, Dimitris Chloupis <kilon.alios@gmail.com> wrote:
I have FFIExternalStructure which has at class side
fieldsDesc ^#( char data[100]; int count; )
if I try to do
EphCPPTestStructure rebuildFieldAccessors .
in order to generate the accessors for the members of the struct it complains with an error that it does not recognise the type of " [ "
Does that mean that char arrays are other arrays are not supported as struct members or will I have to do this manually ?
yes please :)
On 8 Nov 2016, at 13:32, Dimitris Chloupis <kilon.alios@gmail.com> wrote:
then great work^2
Do you want me to add this information to the UFFI documentation ? Probably I will also add some more examples for handles, pointers etc.
I assume this is the repo for the docs of UFFI
https://github.com/SquareBracketAssociates/PharoInProgress <https://github.com/SquareBracketAssociates/PharoInProgress>
correct ?
On Tue, Nov 8, 2016 at 2:12 PM Esteban Lorenzano <estebanlm@gmail.com <mailto:estebanlm@gmail.com>> wrote:
On 8 Nov 2016, at 12:55, Dimitris Chloupis <kilon.alios@gmail.com <mailto:kilon.alios@gmail.com>> wrote:
Thank you Esteban
By the way I really love the design of UFFI , very clean and quite easy to understand , great work to you and Igor :)
UFFI is just mine ;) (but I sanded in giant shoulders as I took Igor work as inspiration⦠and to âborrowâ many cool ideas)
Esteban
On Tue, Nov 8, 2016 at 1:54 PM Esteban Lorenzano <estebanlm@gmail.com <mailto:estebanlm@gmail.com>> wrote:
On 8 Nov 2016, at 12:49, Dimitris Chloupis <kilon.alios@gmail.com <mailto:kilon.alios@gmail.com>> wrote:
I was reaching a similar conclusion
Currently I have a void pointer to the struct with the members I mentioned
I can get char[100]
pointerToStruct fromCString
and I can get the int with
pointerToStruct getHandle integerAt: 101 size:4 signed: false
so if I want to pass the address of the pointer to my YourStruct instance will I have to initialize with
YourStruct fromHandler: (pointerToStruct getHandle)
is this a correct and safe way to pass the address ?
yes.
Esteban
On Tue, Nov 8, 2016 at 1:21 PM Esteban Lorenzano <estebanlm@gmail.com <mailto:estebanlm@gmail.com>> wrote: it never could. you need to do a âspecial typeâ, who has to be something like:
YourStruct class>>initialize Char100 := FFITypeArray ofType: #char.
fieldsDesc ^ #( Char100 data; int count; )
but then⦠you want to optimise that and in field accessors, who will look something like this:
YourStruct >>data "This method was automatically generated" ^(FFITypeArray ofType: #char size: 100) fromHandle: (handle copyFrom: 1 to: 100)
you can change that for:
YourStruct >>data "This method was automatically generated" ^Char100 fromHandle: (handle copyFrom: 1 to: 100)
and same for setter. (other way will work, but it will be suboptimal)
Esteban
On 8 Nov 2016, at 12:10, Dimitris Chloupis <kilon.alios@gmail.com <mailto:kilon.alios@gmail.com>> wrote:
I have FFIExternalStructure which has at class side
fieldsDesc ^#( char data[100]; int count; )
if I try to do
EphCPPTestStructure rebuildFieldAccessors .
in order to generate the accessors for the members of the struct it complains with an error that it does not recognise the type of " [ "
Does that mean that char arrays are other arrays are not supported as struct members or will I have to do this manually ?
by the way your code is wrong there is no FFITypeArray ofType: so it looks I will have to go straight to FFITypeArray ofType:'char' size:100 of course for my case what you mention as FFITypeArray ofType: #char size: 100) fromHandle: (handle copyFrom: 1 to: 100) is the one that does exactly what I want. On Tue, Nov 8, 2016 at 2:38 PM Esteban Lorenzano <estebanlm@gmail.com> wrote:
yes please :)
On 8 Nov 2016, at 13:32, Dimitris Chloupis <kilon.alios@gmail.com> wrote:
then great work^2
Do you want me to add this information to the UFFI documentation ? Probably I will also add some more examples for handles, pointers etc.
I assume this is the repo for the docs of UFFI
https://github.com/SquareBracketAssociates/PharoInProgress
correct ?
On Tue, Nov 8, 2016 at 2:12 PM Esteban Lorenzano <estebanlm@gmail.com> wrote:
On 8 Nov 2016, at 12:55, Dimitris Chloupis <kilon.alios@gmail.com> wrote:
Thank you Esteban
By the way I really love the design of UFFI , very clean and quite easy to understand , great work to you and Igor :)
UFFI is just mine ;) (but I sanded in giant shoulders as I took Igor work as inspiration⦠and to âborrowâ many cool ideas)
Esteban
On Tue, Nov 8, 2016 at 1:54 PM Esteban Lorenzano <estebanlm@gmail.com> wrote:
On 8 Nov 2016, at 12:49, Dimitris Chloupis <kilon.alios@gmail.com> wrote:
I was reaching a similar conclusion
Currently I have a void pointer to the struct with the members I mentioned
I can get char[100]
pointerToStruct fromCString
and I can get the int with
pointerToStruct getHandle integerAt: 101 size:4 signed: false
so if I want to pass the address of the pointer to my YourStruct instance will I have to initialize with
YourStruct fromHandler: (pointerToStruct getHandle)
is this a correct and safe way to pass the address ?
yes.
Esteban
On Tue, Nov 8, 2016 at 1:21 PM Esteban Lorenzano <estebanlm@gmail.com> wrote:
it never could. you need to do a âspecial typeâ, who has to be something like:
YourStruct class>>initialize Char100 := FFITypeArray ofType: #char.
fieldsDesc ^ #( Char100 data; int count; )
but then⦠you want to optimise that and in field accessors, who will look something like this:
YourStruct >>data "This method was automatically generated" ^(FFITypeArray ofType: #char size: 100) fromHandle: (handle copyFrom: 1 to: 100)
you can change that for:
YourStruct >>data "This method was automatically generated" ^Char100 fromHandle: (handle copyFrom: 1 to: 100)
and same for setter. (other way will work, but it will be suboptimal)
Esteban
On 8 Nov 2016, at 12:10, Dimitris Chloupis <kilon.alios@gmail.com> wrote:
I have FFIExternalStructure which has at class side
fieldsDesc ^#( char data[100]; int count; )
if I try to do
EphCPPTestStructure rebuildFieldAccessors .
in order to generate the accessors for the members of the struct it complains with an error that it does not recognise the type of " [ "
Does that mean that char arrays are other arrays are not supported as struct members or will I have to do this manually ?
ah yes⦠I wrote it by heart :P you need to declare the array type size, otherwise there is no point on it :) Char100 := FFITypeArray ofType: aTypeName size: elements. ⦠and the rest is still the same (you replace FFITypeArray class>>ofType:size: occurrences with Char100) Esteban
On 8 Nov 2016, at 14:29, Dimitris Chloupis <kilon.alios@gmail.com> wrote:
by the way your code is wrong there is no FFITypeArray ofType: so it looks I will have to go straight to
FFITypeArray ofType:'char' size:100
of course for my case what you mention as
FFITypeArray ofType: #char size: 100) fromHandle: (handle copyFrom: 1 to: 100)
is the one that does exactly what I want.
On Tue, Nov 8, 2016 at 2:38 PM Esteban Lorenzano <estebanlm@gmail.com <mailto:estebanlm@gmail.com>> wrote: yes please :)
On 8 Nov 2016, at 13:32, Dimitris Chloupis <kilon.alios@gmail.com <mailto:kilon.alios@gmail.com>> wrote:
then great work^2
Do you want me to add this information to the UFFI documentation ? Probably I will also add some more examples for handles, pointers etc.
I assume this is the repo for the docs of UFFI
https://github.com/SquareBracketAssociates/PharoInProgress <https://github.com/SquareBracketAssociates/PharoInProgress>
correct ?
On Tue, Nov 8, 2016 at 2:12 PM Esteban Lorenzano <estebanlm@gmail.com <mailto:estebanlm@gmail.com>> wrote:
On 8 Nov 2016, at 12:55, Dimitris Chloupis <kilon.alios@gmail.com <mailto:kilon.alios@gmail.com>> wrote:
Thank you Esteban
By the way I really love the design of UFFI , very clean and quite easy to understand , great work to you and Igor :)
UFFI is just mine ;) (but I sanded in giant shoulders as I took Igor work as inspiration⦠and to âborrowâ many cool ideas)
Esteban
On Tue, Nov 8, 2016 at 1:54 PM Esteban Lorenzano <estebanlm@gmail.com <mailto:estebanlm@gmail.com>> wrote:
On 8 Nov 2016, at 12:49, Dimitris Chloupis <kilon.alios@gmail.com <mailto:kilon.alios@gmail.com>> wrote:
I was reaching a similar conclusion
Currently I have a void pointer to the struct with the members I mentioned
I can get char[100]
pointerToStruct fromCString
and I can get the int with
pointerToStruct getHandle integerAt: 101 size:4 signed: false
so if I want to pass the address of the pointer to my YourStruct instance will I have to initialize with
YourStruct fromHandler: (pointerToStruct getHandle)
is this a correct and safe way to pass the address ?
yes.
Esteban
On Tue, Nov 8, 2016 at 1:21 PM Esteban Lorenzano <estebanlm@gmail.com <mailto:estebanlm@gmail.com>> wrote: it never could. you need to do a âspecial typeâ, who has to be something like:
YourStruct class>>initialize Char100 := FFITypeArray ofType: #char.
fieldsDesc ^ #( Char100 data; int count; )
but then⦠you want to optimise that and in field accessors, who will look something like this:
YourStruct >>data "This method was automatically generated" ^(FFITypeArray ofType: #char size: 100) fromHandle: (handle copyFrom: 1 to: 100)
you can change that for:
YourStruct >>data "This method was automatically generated" ^Char100 fromHandle: (handle copyFrom: 1 to: 100)
and same for setter. (other way will work, but it will be suboptimal)
Esteban
On 8 Nov 2016, at 12:10, Dimitris Chloupis <kilon.alios@gmail.com <mailto:kilon.alios@gmail.com>> wrote:
I have FFIExternalStructure which has at class side
fieldsDesc ^#( char data[100]; int count; )
if I try to do
EphCPPTestStructure rebuildFieldAccessors .
in order to generate the accessors for the members of the struct it complains with an error that it does not recognise the type of " [ "
Does that mean that char arrays are other arrays are not supported as struct members or will I have to do this manually ?
On 8 November 2016 at 13:11, Esteban Lorenzano <estebanlm@gmail.com> wrote:
On 8 Nov 2016, at 12:55, Dimitris Chloupis <kilon.alios@gmail.com> wrote:
Thank you Esteban
By the way I really love the design of UFFI , very clean and quite easy to understand , great work to you and Igor :)
UFFI is just mine ;) (but I sanded in giant shoulders as I took Igor work as inspiration⦠and to âborrowâ many cool ideas)
Your credit is too generous :)
Btw, is this expression: FFITypeArray ofType: #char. creates anonymous class, or you making an instance of something? Because if it anonymous class, i was always warned against use it in such form, and instead use some kind of class initializers to generate all the 'types' you will use in future i.e. MyCalss class>>initialize MyCharr100Type := FFITypeArray ofType: #char size:100. and then just use it wherever you need i.e.: mychars := MyChar100Type new. .. whatever.
Esteban
On Tue, Nov 8, 2016 at 1:54 PM Esteban Lorenzano <estebanlm@gmail.com> wrote:
On 8 Nov 2016, at 12:49, Dimitris Chloupis <kilon.alios@gmail.com> wrote:
I was reaching a similar conclusion
Currently I have a void pointer to the struct with the members I mentioned
I can get char[100]
pointerToStruct fromCString
and I can get the int with
pointerToStruct getHandle integerAt: 101 size:4 signed: false
so if I want to pass the address of the pointer to my YourStruct instance will I have to initialize with
YourStruct fromHandler: (pointerToStruct getHandle)
is this a correct and safe way to pass the address ?
yes.
Esteban
On Tue, Nov 8, 2016 at 1:21 PM Esteban Lorenzano <estebanlm@gmail.com> wrote:
it never could. you need to do a âspecial typeâ, who has to be something like:
YourStruct class>>initialize Char100 := FFITypeArray ofType: #char.
fieldsDesc ^ #( Char100 data; int count; )
but then⦠you want to optimise that and in field accessors, who will look something like this:
YourStruct >>data "This method was automatically generated" ^(FFITypeArray ofType: #char size: 100) fromHandle: (handle copyFrom: 1 to: 100)
you can change that for:
YourStruct >>data "This method was automatically generated" ^Char100 fromHandle: (handle copyFrom: 1 to: 100)
and same for setter. (other way will work, but it will be suboptimal)
Esteban
On 8 Nov 2016, at 12:10, Dimitris Chloupis <kilon.alios@gmail.com> wrote:
I have FFIExternalStructure which has at class side
fieldsDesc ^#( char data[100]; int count; )
if I try to do
EphCPPTestStructure rebuildFieldAccessors .
in order to generate the accessors for the members of the struct it complains with an error that it does not recognise the type of " [ "
Does that mean that char arrays are other arrays are not supported as struct members or will I have to do this manually ?
-- Best regards, Igor Stasenko.
As a said that expression does not exist The one with size it does exist and creates an instance as you would expect. No idea what an anonymous class is. I have experienced some slow downs because creating FFI types seems that copies the data and Pharo chokes with my 3000 bytes char array. So I decided not to use FFI types and instead fetch the data directly from shared memory via the pointer which means anExternalData getHandle unsignedCharAt: for reading anExternalData getHandle unsignedCharAt: put: for writing Plus copying the data to Pharo memory kinda defeats the purpose of using shared memory in the first place and it's unnecessary . But then I am a special case ... the recommended way remains using those types. On Wed, 9 Nov 2016 at 03:34, Igor Stasenko <siguctua@gmail.com> wrote:
On 8 November 2016 at 13:11, Esteban Lorenzano <estebanlm@gmail.com> wrote:
On 8 Nov 2016, at 12:55, Dimitris Chloupis <kilon.alios@gmail.com> wrote:
Thank you Esteban
By the way I really love the design of UFFI , very clean and quite easy to understand , great work to you and Igor :)
UFFI is just mine ;) (but I sanded in giant shoulders as I took Igor work as inspiration⦠and to âborrowâ many cool ideas)
Your credit is too generous :) Btw, is this expression:
FFITypeArray ofType: #char.
creates anonymous class, or you making an instance of something?
Because if it anonymous class, i was always warned against use it in such form, and instead use some kind of class initializers to generate all the 'types' you will use in future i.e.
MyCalss class>>initialize MyCharr100Type := FFITypeArray ofType: #char size:100.
and then just use it wherever you need i.e.:
mychars := MyChar100Type new.
.. whatever.
Esteban
On Tue, Nov 8, 2016 at 1:54 PM Esteban Lorenzano <estebanlm@gmail.com> wrote:
On 8 Nov 2016, at 12:49, Dimitris Chloupis <kilon.alios@gmail.com> wrote:
I was reaching a similar conclusion
Currently I have a void pointer to the struct with the members I mentioned
I can get char[100]
pointerToStruct fromCString
and I can get the int with
pointerToStruct getHandle integerAt: 101 size:4 signed: false
so if I want to pass the address of the pointer to my YourStruct instance will I have to initialize with
YourStruct fromHandler: (pointerToStruct getHandle)
is this a correct and safe way to pass the address ?
yes.
Esteban
On Tue, Nov 8, 2016 at 1:21 PM Esteban Lorenzano <estebanlm@gmail.com> wrote:
it never could. you need to do a âspecial typeâ, who has to be something like:
YourStruct class>>initialize Char100 := FFITypeArray ofType: #char.
fieldsDesc ^ #( Char100 data; int count; )
but then⦠you want to optimise that and in field accessors, who will look something like this:
YourStruct >>data "This method was automatically generated" ^(FFITypeArray ofType: #char size: 100) fromHandle: (handle copyFrom: 1 to: 100)
you can change that for:
YourStruct >>data "This method was automatically generated" ^Char100 fromHandle: (handle copyFrom: 1 to: 100)
and same for setter. (other way will work, but it will be suboptimal)
Esteban
On 8 Nov 2016, at 12:10, Dimitris Chloupis <kilon.alios@gmail.com> wrote:
I have FFIExternalStructure which has at class side
fieldsDesc ^#( char data[100]; int count; )
if I try to do
EphCPPTestStructure rebuildFieldAccessors .
in order to generate the accessors for the members of the struct it complains with an error that it does not recognise the type of " [ "
Does that mean that char arrays are other arrays are not supported as struct members or will I have to do this manually ?
-- Best regards, Igor Stasenko.
On 9 Nov 2016, at 02:33, Igor Stasenko <siguctua@gmail.com> wrote:
On 8 November 2016 at 13:11, Esteban Lorenzano <estebanlm@gmail.com <mailto:estebanlm@gmail.com>> wrote:
On 8 Nov 2016, at 12:55, Dimitris Chloupis <kilon.alios@gmail.com <mailto:kilon.alios@gmail.com>> wrote:
Thank you Esteban
By the way I really love the design of UFFI , very clean and quite easy to understand , great work to you and Igor :)
UFFI is just mine ;) (but I sanded in giant shoulders as I took Igor work as inspiration⦠and to âborrowâ many cool ideas)
Your credit is too generous :) Btw, is this expression:
FFITypeArray ofType: #char.
creates anonymous class, or you making an instance of something?
Because if it anonymous class, i was always warned against use it in such form, and instead use some kind of class initializers to generate all the 'types' you will use in future i.e.
MyCalss class>>initialize MyCharr100Type := FFITypeArray ofType: #char size:100.
and then just use it wherever you need i.e.:
mychars := MyChar100Type new.
is exactly like you say :) Esteban
.. whatever.
Esteban
On Tue, Nov 8, 2016 at 1:54 PM Esteban Lorenzano <estebanlm@gmail.com <mailto:estebanlm@gmail.com>> wrote:
On 8 Nov 2016, at 12:49, Dimitris Chloupis <kilon.alios@gmail.com <mailto:kilon.alios@gmail.com>> wrote:
I was reaching a similar conclusion
Currently I have a void pointer to the struct with the members I mentioned
I can get char[100]
pointerToStruct fromCString
and I can get the int with
pointerToStruct getHandle integerAt: 101 size:4 signed: false
so if I want to pass the address of the pointer to my YourStruct instance will I have to initialize with
YourStruct fromHandler: (pointerToStruct getHandle)
is this a correct and safe way to pass the address ?
yes.
Esteban
On Tue, Nov 8, 2016 at 1:21 PM Esteban Lorenzano <estebanlm@gmail.com <mailto:estebanlm@gmail.com>> wrote: it never could. you need to do a âspecial typeâ, who has to be something like:
YourStruct class>>initialize Char100 := FFITypeArray ofType: #char.
fieldsDesc ^ #( Char100 data; int count; )
but then⦠you want to optimise that and in field accessors, who will look something like this:
YourStruct >>data "This method was automatically generated" ^(FFITypeArray ofType: #char size: 100) fromHandle: (handle copyFrom: 1 to: 100)
you can change that for:
YourStruct >>data "This method was automatically generated" ^Char100 fromHandle: (handle copyFrom: 1 to: 100)
and same for setter. (other way will work, but it will be suboptimal)
Esteban
On 8 Nov 2016, at 12:10, Dimitris Chloupis <kilon.alios@gmail.com <mailto:kilon.alios@gmail.com>> wrote:
I have FFIExternalStructure which has at class side
fieldsDesc ^#( char data[100]; int count; )
if I try to do
EphCPPTestStructure rebuildFieldAccessors .
in order to generate the accessors for the members of the struct it complains with an error that it does not recognise the type of " [ "
Does that mean that char arrays are other arrays are not supported as struct members or will I have to do this manually ?
-- Best regards, Igor Stasenko.
participants (3)
-
Dimitris Chloupis -
Esteban Lorenzano -
Igor Stasenko