From: Lorien Dunn Date: 2002-04-18T02:04:01+09:00 Subject: Re: visual c, ruby, and fastcall hassle On Wednesday 17 April 2002 10:28 pm, nobu.nokada@softhome.net wrote: > Hi, > > At Wed, 17 Apr 2002 19:58:27 +0900, > > Lorien Dunn wrote: > > today I tried to embed ruby in a computer game I'm working on. It uses > > Auran's Jet 3d engine (www.auranjet.com), which is closed source, and > > requires projects using it to be compiled with fastcall enabled. Fastcall > > is a calling convention that does not permit variable numbers of > > arguments for the sake of speed. However, by prefixing every function > > prototype in "ruby.h" and "intern.h" with __cdecl I succeeded in building > > the app. > > Since __cdecl is default, that Jet 3d engine's header should > have __fastcall? No, because you have to set __fastcall as default in the project settings. If all the Jet headers used __fastcall it would not be a problem. > > > Then I tried writing a linked in extension in c, and got a type error > > from the function ptr argument of "rb_define_method": it wanted a VALUE > > _cdcel (*) (VALUE, VALUE), and was getting a VALUE __fastcall (*) > > (VALUE,VALUE), so I declared my function as _cdecl and recieved the same > > error! > > You can write wrapper functions. All I was doing was something like this in a project with __fastcall as default: static VALUE cTest; static VALUE __cdecl cTestBang(VALUE self,VALUE arg) { rb_iv_set(self,"@arg",arg); puts("Bang!"); } void Init_Test() { rb_iv_set cTest = rb_define_class("Test"); rb_define_method(cTest,"Bang",cTestBang,0); } and linking this in with the application that embeds ruby and links to jet, and calling Init_Test() after ruby_init(). So I'm afraid I don't understant what you mean I should wrap. I'm not wanting to wrap Jet- just make the needful parts of the game scriptable. Thanks, Lorien