help-smalltalk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re : [Help-smalltalk] Passing a struct to a c-callout


From: Mathieu Suen
Subject: Re : [Help-smalltalk] Passing a struct to a c-callout
Date: Fri, 18 Feb 2011 09:14:20 +0000 (GMT)

Hi 

Eventually it is a bit more complicate. I thought I could make it simpler but 
not.
The complete example is that I want to call a objective-c method that take a 
struct as parameter:

@interface  NSWindow
- (id)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)windowStyle 
backing:(NSBackingStoreType)bufferingType defer:(BOOL)deferCreation
@end


The first parameter is a NSRect. 
NSrect is a struct of basically 4 double on 64bit platform.
I call the method  #initWithContentRect:styleMask:backing:defer: using the 
objective-c runtime:
void 
objc_msgSend(id receiver, SEL msg, ...);

My cCall to objc_msgSend is define as follow:

ObjcRuntime class >> objcMsgSend: receiver selector: sel args: args [
    <cCall: 'objc_msgSend' returning: #cObject args: #( #cObject #cObject 
#variadic )>
]

I have also define the struct NSRect as follow:

CStruct subclass: NSRect [
    <declaration: #( (#x #double) (#y #double) (#w #double) (#h #double) )>
]

But the invocation doesn't work:

nsRect :=  NSRect new.
  nsRect x value: 0.0.
  nsRect y value: 0.0.
  nsRect w value: 100.0.
  nsRect h value: 100.0
ObjcRuntime  objcMsgSend: nsWindow selector: initSeld args: {nsRect. 15. 2. 1}.



Thanks



----- Message d'origine ----
> De : Holger Hans Peter Freyther <address@hidden>
> À : Mathieu Suen <address@hidden>
> Cc : address@hidden
> Envoyé le : Jeu 17 février 2011, 23h 01min 01s
> Objet : Re: [Help-smalltalk] Passing a struct to a c-callout
> 
> On 02/17/2011 09:29 PM, Mathieu Suen wrote:
> 
> > oops sorry in fact I  mean:
> > 
> > foo: list [
> >     <cCall: 'foo'  returning: #void args: #( #variadic )>
> > ]
> 
> could you create an  example that works with the C library? e.g. printf (but
> paolo was already  adding a binding for that). And doesn't va_start need the
> argument of the  last type? this would mean that args should be something like
> #(#something  #variadic)?
> 






reply via email to

[Prev in Thread] Current Thread [Next in Thread]