|
Re: Minor Bug in Java directors, and a patch: msg#00109programming.swig
The JNI method ID pointer gets initialized when the swig_connect_director method gets called. I agree that the warning is annoying, but it's not a bug (otherwise, a lot of director calls wouldn't work.) IIRC, if one doesn't specify an initializer, most compilers simply initialize the space to zero. I don't recall what the C or C++ standard says on the subject, off the top of my head. On Tue, 14 Sep 2004 13:40:43 +0800, Russell Keith-Magee <russell.magee@xxxxxxxxxxxx> wrote: > > Hi all, > > I've been using Directors in a project; I have had no problem with usage, > but I am getting an annoying warning during compilation. I've found the > culprit, and I've attached a patch for the problem. > > Here's a test case. Using the following interface definition: > --- test.i > %module(directors="1") test > %{ > %} > > %feature("director") MyClass; > > class MyClass > { > public: > virtual ~MyClass() {} > virtual int method() = 0; > }; > --- > Generate the swig bindings with: > > swig -c++ -java -o test_wrap.cpp test.i > > When compiled on a gcc3 compiler with -Wall, generates the warning: > > missing initializer for member > SwigDirector_MyClass::swig_connect_director(JNIEnv *, _jobject*, _jclass > *)::<anonymous struct>::base_methid > > The problem is caused by the structure that is defined to store the virtual > method names, parameter types, and JNI method ID's. The method name and > parameter types are filled in, but the JNI method ID is left uninitialized. > > This doesn't generate a warning under gcc2.96, or under Visual Studio 6. > > The following patch fixes the problem. All it does is specify an > initialization value of NULL for the JNI method ID. The fix is on line 3506 > of Modules/java.cxx. > > *** java.cxx.fix Tue Sep 14 13:00:06 2004 > --- java.cxx.old Tue Sep 14 12:58:28 2004 > *************** > *** 3503,3509 **** > for (int i = first_class_dmethod; i < curr_class_dmethod; ++i) { > UpcallData *udata = Getitem(dmethods_seq, i); > > ! Printf(w->def, "{ \"%s\", \"%s\", NULL }", Getattr(udata, > "method"), Geta > ttr(udata, "fdesc")); > if (i != curr_class_dmethod - 1) > Putc(',', w->def); > Putc('\n', w->def); > --- 3503,3509 ---- > for (int i = first_class_dmethod; i < curr_class_dmethod; ++i) { > UpcallData *udata = Getitem(dmethods_seq, i); > > ! Printf(w->def, "{ \"%s\", \"%s\" }", Getattr(udata, "method"), > Getattr > (udata, "fdesc")); > if (i != curr_class_dmethod - 1) > Putc(',', w->def); > Putc('\n', w->def); > > Yours, > Russ Magee > > -- > Dr Russell Keith-Magee <russell.magee@xxxxxxxxxxxx> > Software Engineer > Calytrix Technologies > Ph: +61 8 9325 5600 > Fax: +61 8 9325 5400 Dr. Scott Michel <scottm@xxxxxxxx> Senior Member, Technical Staff The Aerospace Corporation _______________________________________________ Swig maillist - Swig@xxxxxxxxxxxxxxx http://mailman.cs.uchicago.edu/mailman/listinfo/swig |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: Preventing a user to refer to non-existent struct members: 00109, Josh Cherry |
|---|---|
| Next by Date: | Re: Preventing a user to refer to non-existent struct members: 00109, Robert Lupton |
| Previous by Thread: | Re: Minor Bug in Java directors, and a patchi: 00109, William S Fulton |
| Next by Thread: | C++ static variable prob: 00109, Alexander Tournier |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |