From: Simon Strandgaard <0bz63fz3m1qt3001@...> Date: 2003-04-10T11:42:33+09:00 Subject: Re: embedding ruby with swig On Wed, 09 Apr 2003 17:56:52 +0000, Steve Hart wrote: > > static void GMScript_freefunc(void *ptr) > { > cerr << "FREE\n"; > GMScript *script = (GMScript *) ptr; > delete script; > } I think its overkill to have your own freefunc when SWIG can generate one for you for free. If you want to output some debug information when the instance gets destroyed (swept by GC), you can do it from your destructor. GMScript::~GMScript() { cerr << "FREE\n"; } > static void GMScript_markfunc(void *ptr) > { > cerr << "MARK\n"; > GMScript *script = (GMScript *) ptr; > rb_gc_mark(reinterpret_cast((script->scriptObj))); > } Yes, its correct that "scriptObj" needs to be marked during GC. No, you cannot cast the argument like that. Try: VALUE GMScript_markfunc(VALUE self) { GMScript *p; Data_Get_Struct(self, GMScript, p); rb_gc_mark(reinterpret_cast((p->scriptObj))); return self; } > GMScript.h > GMScript.cpp Looks fine.. to me :-) > main.c maybe rename it into main.cpp ? hmmm... lets take than in another posting :-) -- Simon Strandgaard