|
FW:: msg#00115programming.swig
Hi All, I want to add some more findings to my previous question. By making the functions non-virtual I am able to solve my problem successfully, but I do not intend to be doing that, as I will loose the advantage of having them. If any c++ expert can help me on this, I really appreciate for there help. Thank you > -----Original Message----- > From: Devender Marri > Sent: Thursday, May 20, 2004 1:36 PM > To: 'swig@xxxxxxxxxxxxxxx' > Subject: > > Hi All, > > Sorry my previous description was not clear, so adding more description. > > Issue: Memory corruption. > > Operating System - Linux > JDK - 1.4.2 > gcc - 3.0 > > I had an header file of the format > > class DtInteraction :: public DtBaseInteraction > { > public: > virtual void setRequestId(int id); > virtual int requestId() const; > protected: > int myRequestId; > } > > class DtBaseInteraction > { > virtual void setNum(int newNum); > virtual int getNum() const; > protected: > int myNum; > } > > I do not have implementation for the above classes, but I assume the > implementation should be straight forward. > I have the library file libImpl.so which allows me to access the above > methods. > > I used swig to generate the wrapper classes for the above. > > I create a test java class as shown below > { > . > . > DtInteraction test = new DtInteraction(); > test.setRequestId(100); > System.out.println("RequestId value is " + test.getRequestId()); > > test.setNum(101); > System.out.println("my number is " + test.getNum()); > } > > The output of the above test is as follows > RequestIdValue is 144322456 > my number is 101 > > > My comments > 1) The value returned by getRequestId is not the same as the value. It is > equal to the value of test.getCptr() or the address of the c++ object. > 2) Was able to successfully receive the base class value. > > I had written a c++ program to ensure that setRequestId is indeed setting the > correct values. > > test cpp class is as follows > { > DtInteraction* test = new DtInteraction(); > test->setRequestId(100); > cout << "request id value is " << test->getRequestId() << endl > } > > The output of the above implementation is > request id value is 100 > > > My Comments: > From the above test I found the library which I am using for java testing is > indeed correct. > > > > Conclusion: > I know that It looks pretty strange, but I face this problem, > I had my own set, get methods to the header file and generated the wrapper > and java classes and tested > and found that those does not have any problem. > > Example: > class DtInteraction :: public DtBaseInteraction > { > public: > . > . > virtual void setMyNum(int num) > { > myNum = num; > } > virutal int getMyNum() const > { > return myNum > } > } > > The above method returns correct value when accessed from java. > > U are always welcome to demand more information from me. > > I really appreciate if some body can help me. > > Thank you. > > > > > > > > > Regards > Marri Devender Rao > Software Engineer > 24, Ang Mo Kio Street 65, > Singapore 569061 > Phone: 64131381(O), 65833061(H) > _______________________________________________ Swig maillist - Swig@xxxxxxxxxxxxxxx http://mailman.cs.uchicago.edu/mailman/listinfo/swig |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | How to install tclpro on linux: 00115, Hu, Luhui |
|---|---|
| Next by Date: | Re: typenames.i, double * and python: 00115, Marcelo Matus |
| Previous by Thread: | How to install tclpro on linuxi: 00115, Hu, Luhui |
| Next by Thread: | "inheritance" order in Perl proxies: 00115, Josh Cherry |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |