discuss-gnustep
[Top][All Lists]
Advanced

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

Re: Wrapping C functions


From: Martin Kalbfuß
Subject: Re: Wrapping C functions
Date: Thu, 6 Aug 2009 10:24:39 -0700 (PDT)

Is the initalize method called automatically or has the user to call it?


David Chisnall wrote:
> 
> On 6 Aug 2009, at 17:48, Martin Kalbfuß wrote:
> 
>> Some functions belong clearly to an object, like the bitmap  
>> functions for
>> example. But I don't know whhere to put functions like SDL_init.  
>> Should I
>> create a library object or system object or something?
> 
> The best place for things like this is inside a +initialize method.   
> On some object wrapping global SDL state, add this method:
> 
> + (void)initialize
> {
>       // Protect from calls by subclass
>       if (self != [SDLState class]) return;
> 
>       SDL_init();
>       // Any other library initialization that you need.
> }
> 
> This method will be called exactly once the first time the SDLState  
> class receives.  In order to instantiate the class, you send it an  
> +alloc (or similar) message, so this will be called before the first  
> time you create an instance of the class.
> 
> David
> 
> _______________________________________________
> Discuss-gnustep mailing list
> Discuss-gnustep@gnu.org
> http://lists.gnu.org/mailman/listinfo/discuss-gnustep
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Wrapping-C-functions-tp24850281p24850965.html
Sent from the GNUstep - General mailing list archive at Nabble.com.





reply via email to

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