From: William S F. <ws...@fu...> - 2008-06-14 11:18:50
|
Works for me with one modification qualifying the vector namespace. Here is a full example you can paste into an interface file: %module example %include "inttypes.i" %include "std_vector.i" namespace std { %template(almanac_vector) vector<uint8_t>; // %template(dataFromIc_vector) vector<uint8_t>; }; %inline %{ typedef std::vector<uint8_t> almanac_vector; typedef std::vector<uint8_t> dataFromIc_vector; void setAlmanac(const almanac_vector& svGlobalHealth); void rcvSerialData(const dataFromIc_vector& dataFromIc); %} William Dwarkanath Radhakrishnan wrote: > Hi David, > Thanks for the reply.... > But I do have %include IMsg.h in my interface file.... I have it after > the templates I have defined and before the %include example.h directive > I forgot to show it here in the one I posted.... > But I still have the same problem... > > -Dwarak > > On Wed, Jun 11, 2008 at 10:29 AM, David Piepgrass > <dpi...@me... <mailto:dpi...@me...>> wrote: > > I think the problem is that your .i file doesn't %include IMsg.h. You > need to include that file or else put these typedefs in example.i: > > typedef vector<uint8_t> almanac_vector; > typedef vector<uint8_t> dataFromIc_vector; > > > -----Original Message----- > > From: swi...@li... > <mailto:swi...@li...> [mailto:swig-user- > <mailto:swig-user-> > > bo...@li... > <mailto:bo...@li...>] On Behalf Of Dwarkanath > Radhakrishnan > > Sent: Tuesday, June 10, 2008 8:31 PM > > To: swi...@li... > <mailto:swi...@li...> > > Subject: [Swig-user] Question regarding using std::vectors with Java > > > > Hi all, > > > > I'm new to swig and this might look like a simple qtn... but I > couldn't > > find answers to this when I searched it online. The qtn is as > follows: > > > > Consider I have a header file named IMsg.h wherre I do the following: > > > > /* Filename IMsg.h > > { > > typedef vector<uint8_t> almanac_vector; > > typedef vector<uint8_t> dataFromIc_vector; > > > > ... > > .. > > } > > > > Now in another file named example.h I have a function > > { > > virtual void setAlmanac(const almanac_vector& > svGlobalHealth); > > > > virtual void rcvSerialData(const dataFromIc_vector& > dataFromIc > ) > > ..... > > .... > > } > > > > Now my interface file looks like this: > > // Filename example.i > > %module test > > > > %{ > > #include "example.h" > > %} > > > > /* Let's just grab the original header file here */ > > %include "inttypes.i" > > %include "std_vector.i" > > namespace std { > > %template(almanac_vector) vector<uint8_t>; > > %template(dataFromIc_vector) vector<uint8_t>; > > }; > > %include example.h > > > > > > So I have included inttypes.i (for uint8_t type)and std_vector.i( for > > using std::vectors)........ > > But when I create Java wrapper class for this example.h , the > function > > setAlmanac() in example.java looks like this: > > setAlmanac(SWIGTYPE_p_vectorT_unsigned_char_t svGlobalHealth); > > > > Why is it not taking almanac_vector data type as one of the arguments > > since I've already declared the template for it?? why is it taking > some > > weird SWIGTYPE_p_vectorT_unsigned_char_t data type as its argument?? > > > > Thanks > > Dwarak > > > > > > > > > > > > > > > > > > > ------------------------------------------------------------------------ > > ------------------------------------------------------------------------- > Check out the new SourceForge.net Marketplace. > It's the best place to buy or sell services for > just about anything Open Source. > http://sourceforge.net/services/buy/index.php > > > ------------------------------------------------------------------------ > > _______________________________________________ > Swig-user mailing list > Swi...@li... > https://lists.sourceforge.net/lists/listinfo/swig-user |