Rajendra Paul | 1 Mar 2003 01:29
Favicon

Mapping std::map and std::pair to Java

Has someone mapped std::pair and std::map in c++ to Java ?

Is that a realistic thing to try to do?

Regards,

Raj 

_______________________________________________
Swig maillist  -  Swig <at> cs.uchicago.edu
http://mailman.cs.uchicago.edu/mailman/listinfo/swig

Drummonds, Scott B | 1 Mar 2003 20:21
Picon
Favicon

new_Struct Not Created

Hello, everyone,

I've SWIG-wrapped a legacy C library for a TCL project and am having
problems with one aspect of SWIG.  For some reason, SWIG isn't
generating the memory allocation function for a structure that is being
wrapped.  Meaning, my structure, which I'll call Struct, isn't having a
new_Struct procedure created.  Since the API for this library requires
pointers to previously allocated objects, I believe I need to have this
function.

I'm invoking SWIG with only the "-tcl" option, but have also tried it
with "-c++".  The .c (or .cxx) wrapper files that are created don't
contain these allocation functions either way.

Can anyone tell me what I'm doing wrong?

Thanks,
Scott
_______________________________________________
Swig maillist  -  Swig <at> cs.uchicago.edu
http://mailman.cs.uchicago.edu/mailman/listinfo/swig

David Beazley | 1 Mar 2003 21:05
Favicon

new_Struct Not Created

Drummonds, Scott B writes:
 > Hello, everyone,
 > 
 > I've SWIG-wrapped a legacy C library for a TCL project and am having
 > problems with one aspect of SWIG.  For some reason, SWIG isn't
 > generating the memory allocation function for a structure that is being
 > wrapped.  Meaning, my structure, which I'll call Struct, isn't having a
 > new_Struct procedure created.  Since the API for this library requires
 > pointers to previously allocated objects, I believe I need to have this
 > function.
 > 
 > I'm invoking SWIG with only the "-tcl" option, but have also tried it
 > with "-c++".  The .c (or .cxx) wrapper files that are created don't
 > contain these allocation functions either way.
 > 
 > Can anyone tell me what I'm doing wrong?

Did you actually tell SWIG about the struct in the interface file?
And what version of SWIG is this?

-- Dave

_______________________________________________
Swig maillist  -  Swig <at> cs.uchicago.edu
http://mailman.cs.uchicago.edu/mailman/listinfo/swig

Juraj Bednar | 1 Mar 2003 21:28
Picon

variable type arguments

Hello,

 I would like to use swig to add scripting possibility to my
 "intelligent bot" for silc network (silcnet.org). There's one
 particular problem. I have a function like this:

 samadhi_signal_emit("signal name",5,arg1,arg2,arg3,arg4,arg5);

 There can be up to 10 args (this is configurable with define) and the
 argument type depends on the emitted signal. Now what with type
 conversion. 

 I can create a list of signal<->argument types mapping, but it will be
 availaible only on runtime. The question is, if it is possible to
 make some use of argument mappings.

 I need to access simple data types (int, char*, ...) and also some
 structures (SilcClient*, SilcClientConnection*). I can work with them
 using wrapper functions like:

 char *samadhi_get_silcclientconnection_servername(SilcClient *client) {
	return client->remote_host;
 }

 So all I need to do is to access them like a pointer. I hope you get
 the idea (if I implemented it without swig, I would create a hash table
 of SilcClient* <-> unique id mapping and would pass unique ID). 

 I hope you understand what I want to do :). Any pointers, URLs,
 examples, similiar projects appreciated.
(Continue reading)

David Beazley | 1 Mar 2003 21:39
Favicon

variable type arguments

 > 
 >  So all I need to do is to access them like a pointer. I hope you get
 >  the idea (if I implemented it without swig, I would create a hash table
 >  of SilcClient* <-> unique id mapping and would pass unique ID). 
 > 

It's not entirely clear to me what you are trying to do.  However,
either typemaps will apply or maybe the material in the variable
length arguments section of the docs.

 >  I hope you understand what I want to do :). Any pointers, URLs,
 >  examples, similiar projects appreciated.
 > 

http://www.swig.org/Doc1.3/Typemaps.html
http://www.swig.org/Doc1.3/Varargs.html

Good luck ;-).

Cheers,
Dave
_______________________________________________
Swig maillist  -  Swig <at> cs.uchicago.edu
http://mailman.cs.uchicago.edu/mailman/listinfo/swig

Drummonds, Scott B | 2 Mar 2003 08:27
Picon
Favicon

RE: new_Struct Not Created

From: David Beazley [mailto:beazley <at> cs.uchicago.edu] 
> Did you actually tell SWIG about the struct in the interface file?
> And what version of SWIG is this?

Yes, doubly so.  My SWIG interface file contains a %include line to the
header file used for source files that will be linking the library.  So,
the %include'd header file definitely contains a definition (not just a
declaration) for the structure that I plan on using.

Plus, I redefined the structure that I'm interesed in in the SWIG
interface file to make its members look like integers.  The original
structure contains integers being stored in 8-bit characters and
integers, while the redefinition of this structure in my interface file
contains only integers to stop SWIG's implicit character-to-integer
conversion.

'swig -version' returns: 1.3.9u-20020228-1139

Scott
_______________________________________________
Swig maillist  -  Swig <at> cs.uchicago.edu
http://mailman.cs.uchicago.edu/mailman/listinfo/swig

Juraj Bednar | 2 Mar 2003 10:46
Picon

Re: variable type arguments

Hello,

> It's not entirely clear to me what you are trying to do.  However,
> either typemaps will apply or maybe the material in the variable
> length arguments section of the docs.

> http://www.swig.org/Doc1.3/Typemaps.html
> http://www.swig.org/Doc1.3/Varargs.html

thanks, this helped on most of the things. However I still don't
understand how to tell SWIG about types during runtime. I mean, I have
a function like this:

void function(int a, void* a1, void* a2);

if ((a==7) && (moonphase==MPHASE_FULL)) {

   // a1 is integer and a2 is char *

} else {
   // a2 is some weird struct (MoonPhase*) and a1 is int
}

(I can have several of these). I still don't get how to tell
swig about the parameters and their types at runtimes. Typemaps
are build-time only, or not? 

    J.

_______________________________________________
(Continue reading)

David Beazley | 2 Mar 2003 13:30
Favicon

Re: variable type arguments

Juraj Bednar writes:
 > Hello,
 > 
 > > It's not entirely clear to me what you are trying to do.  However,
 > > either typemaps will apply or maybe the material in the variable
 > > length arguments section of the docs.
 > 
 > > http://www.swig.org/Doc1.3/Typemaps.html
 > > http://www.swig.org/Doc1.3/Varargs.html
 > 
 > thanks, this helped on most of the things. However I still don't
 > understand how to tell SWIG about types during runtime. I mean, I have
 > a function like this:
 > 
 > void function(int a, void* a1, void* a2);
 > 
 > 
 > if ((a==7) && (moonphase==MPHASE_FULL)) {
 > 
 >    // a1 is integer and a2 is char *
 > 
 > } else {
 >    // a2 is some weird struct (MoonPhase*) and a1 is int
 > }
 > 
 > (I can have several of these). I still don't get how to tell
 > swig about the parameters and their types at runtimes. Typemaps
 > are build-time only, or not? 

Since typemaps perform runtime type conversion, you can (in principle) 
(Continue reading)

David Beazley | 2 Mar 2003 13:37
Favicon

RE: new_Struct Not Created

Drummonds, Scott B writes:
 > From: David Beazley [mailto:beazley <at> cs.uchicago.edu] 
 > > Did you actually tell SWIG about the struct in the interface file?
 > > And what version of SWIG is this?
 > 
 > Yes, doubly so.  My SWIG interface file contains a %include line to the
 > header file used for source files that will be linking the library.  So,
 > the %include'd header file definitely contains a definition (not just a
 > declaration) for the structure that I plan on using.
 > 
 > Plus, I redefined the structure that I'm interesed in in the SWIG
 > interface file to make its members look like integers.  The original
 > structure contains integers being stored in 8-bit characters and
 > integers, while the redefinition of this structure in my interface file
 > contains only integers to stop SWIG's implicit character-to-integer
 > conversion.
 > 

Without seeing a specific example, I have no idea why SWIG wouldn't
generate a default constructor for a structure.  There are really only
a few possibilities; SWIG never sees the structure (run swig -E to see
what's being parsed), default constructor creation has been disabled
(-nodefault, etc.), or the structure has some weird property that
prevents SWIG from generate constructor code (the presence of a pure
virtual method for instance).

 > 'swig -version' returns: 1.3.9u-20020228-1139

You might want to upgrade ;-).

(Continue reading)

Juraj Bednar | 2 Mar 2003 16:26
Picon

Re: variable type arguments

Hello,
> %typemap(in) void *a1 {
>     $1 = PyInt_AsInt($input);
> }

one more question. Is it possible to do this independent on target
language?

     Juraj.

_______________________________________________
Swig maillist  -  Swig <at> cs.uchicago.edu
http://mailman.cs.uchicago.edu/mailman/listinfo/swig


Gmane