Hi everybody!
I am going to write the XCB binding for GNU Smalltalk and now I'm playng with C call-outs. I've got an issue in the case when C function returns a structure itself (not a pointer). There are two files in attachments: * rootwin.c - the C code that aquires current screen and prints the root window's ID * xcbroot.st - the Smalltalk port of rootwin.c `--> ./rootwin root window 163 `--> gst -f xcbroot.st xcbroot.st:56: Aborted (ip 10)CUInt(CScalar)>>#value (ip 6)UndefinedObject>>#executeStatements (ip 0)<bottom> zsh: abort gst -f xcbroot.st I assume that I missunderstood something about pointer-to-structure conversions, however I wrote this code according to GST manual (C data types, etc). I think I did something wrong. Could anybody please help me with this problem? _______________________________________________ help-smalltalk mailing list [hidden email] http://lists.gnu.org/mailman/listinfo/help-smalltalk |
Hi,
The bug is here : (#data (#ptr #XcbScreen)) Change this line with : (#data #{XcbScreen}) Cheers, Gwenael On Sun, 2009-09-27 at 21:04 +0400, Dmitry Matveev wrote: > Hi everybody! > > I am going to write the XCB binding for GNU Smalltalk and now I'm > playng with C call-outs. > > I've got an issue in the case when C function returns a structure > itself (not a pointer). > > There are two files in attachments: > * rootwin.c - the C code that aquires current screen and prints the > root window's ID > * xcbroot.st - the Smalltalk port of rootwin.c > > `--> ./rootwin > root window 163 > > `--> gst -f xcbroot.st > xcbroot.st:56: Aborted > (ip 10)CUInt(CScalar)>>#value > (ip 6)UndefinedObject>>#executeStatements > (ip 0)<bottom> > zsh: abort gst -f xcbroot.st > > I assume that I missunderstood something about pointer-to-structure > conversions, however I wrote this code according to GST manual (C data > types, etc). I think I did something wrong. > > Could anybody please help me with this problem? > _______________________________________________ > help-smalltalk mailing list > [hidden email] > http://lists.gnu.org/mailman/listinfo/help-smalltalk _______________________________________________ help-smalltalk mailing list [hidden email] http://lists.gnu.org/mailman/listinfo/help-smalltalk |
In reply to this post by Dmitry Matveev
On 09/27/2009 07:04 PM, Dmitry Matveev wrote:
> Hi everybody! > > I am going to write the XCB binding for GNU Smalltalk and now I'm > playng with C call-outs. > > I've got an issue in the case when C function returns a structure > itself (not a pointer). In this case, you should create a wrapper to xcb_setup_roots_iterator that accepts a pointer to the structure and copies the return value there. Paolo _______________________________________________ help-smalltalk mailing list [hidden email] http://lists.gnu.org/mailman/listinfo/help-smalltalk |
In reply to this post by MrGwen
Thank you for advice, Gwenael, however unfortunately it did not solved
the problem :( 2009/9/28, Gwenael Casaccio <[hidden email]>: > Hi, > > The bug is here : > > (#data (#ptr #XcbScreen)) > > Change this line with : > > (#data #{XcbScreen}) Regards, Dmitry _______________________________________________ help-smalltalk mailing list [hidden email] http://lists.gnu.org/mailman/listinfo/help-smalltalk |
In reply to this post by Paolo Bonzini-2
> In this case, you should create a wrapper to xcb_setup_roots_iterator
> that accepts a pointer to the structure and copies the return value there. > Thank you, Paolo! I've made the following: void gst_xcb_setup_roots_iterator (const xcb_setup_t *setup, xcb_screen_iterator_t *iter) { if (setup && iter) *iter = xcb_setup_roots_iterator (setup); } in my shared library and Xcb class >> setupRootsIterator: aSetup ptr: iterPtr [ <cCall: 'gst_xcb_setup_roots_iterator' returning: #void args: #(#cObject #{XcbScreenIterator})> ] in the gst binding.. Now it works!! Regards, Dmitry _______________________________________________ help-smalltalk mailing list [hidden email] http://lists.gnu.org/mailman/listinfo/help-smalltalk |
In reply to this post by Dmitry Matveev
Hmm I forget to say that you should also change the line
screen := iter data value. by this : screen := iter data. I've tested it with the c and the st works and it works. Do you have a git rep or a place where we can found the binding ? Cheers, Gwenael On Mon, 2009-09-28 at 23:49 +0400, Dmitry Matveev wrote: > Thank you for advice, Gwenael, however unfortunately it did not solved > the problem :( > > 2009/9/28, Gwenael Casaccio <[hidden email]>: > > Hi, > > > > The bug is here : > > > > (#data (#ptr #XcbScreen)) > > > > Change this line with : > > > > (#data #{XcbScreen}) > > Regards, > Dmitry _______________________________________________ help-smalltalk mailing list [hidden email] http://lists.gnu.org/mailman/listinfo/help-smalltalk |
In reply to this post by Dmitry Matveev
On 09/28/2009 09:52 PM, Dmitry Matveev wrote:
>> In this case, you should create a wrapper to xcb_setup_roots_iterator >> that accepts a pointer to the structure and copies the return value there. >> > > Thank you, Paolo! > > I've made the following: > > void > gst_xcb_setup_roots_iterator (const xcb_setup_t *setup, > xcb_screen_iterator_t *iter) > { if (setup&& iter) > *iter = xcb_setup_roots_iterator (setup); > } > > in my shared library and > > Xcb class>> setupRootsIterator: aSetup ptr: iterPtr [ > <cCall: 'gst_xcb_setup_roots_iterator' returning: #void args: > #(#cObject #{XcbScreenIterator})> > ] > > in the gst binding.. Now it works!! Yes, that's exactly what I meant. Nice that it works! :-) Paolo _______________________________________________ help-smalltalk mailing list [hidden email] http://lists.gnu.org/mailman/listinfo/help-smalltalk |
Free forum by Nabble | Edit this page |