julien CLEMENT | 1 Dec 2008 17:37
Picon
Favicon

Perl Export

Hi all,

I'm new to SWIG. I'm using it to interface Perl and C.
I've noticed that the generated .pm did not export the symbols:

<at> EXPORT = qw ();



-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Swig-user mailing list
Swig-user <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/swig-user
julien CLEMENT | 1 Dec 2008 17:40
Picon
Favicon

Perl Export (2)

Hi all,

I'm new to SWIG. I'm using it to interface Perl and C.
I've noticed that the generated .pm did not export the symbols:

<at> EXPORT = qw ();

Thus, it forces a client program to prefix each symbol with the name of the package or
to do a "pakage <name>;"
If a program uses more than one package, it can be messy to switch between the namespaces.

Is there a way to force the export of the Perl symbols in the generated .pm ?

Many thanks
Julien CLEMENT.

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Swig-user mailing list
Swig-user <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/swig-user
Josh Cherry | 1 Dec 2008 17:47
Picon
Favicon

Re: Perl Export (2)


On Mon, 1 Dec 2008, julien CLEMENT wrote:

> I'm new to SWIG. I'm using it to interface Perl and C.
> I've noticed that the generated .pm did not export the symbols:
>
>  <at> EXPORT = qw ();
>
> Thus, it forces a client program to prefix each symbol with the name of the package or
> to do a "pakage <name>;"
> If a program uses more than one package, it can be messy to switch between the namespaces.
>
> Is there a way to force the export of the Perl symbols in the generated .pm ?

You can add any Perl code you like by using %perlcode (see the Perl 
section of the manual).

Josh

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
julien CLEMENT | 1 Dec 2008 19:38
Picon
Favicon

Perl Export

%perlcode:

Ok, nice idea. Nevertheless, I'd have to export manually all the symbols when it could have been done
automatically, which I expect SWIG to do ...

See you

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
Christopher Barker | 1 Dec 2008 20:43
Picon
Favicon

Re: converting c float array to numpy array or python list

Rich E wrote:
> So I have a nice C library wrapped in python and I'd like to start
> doing some plots of things in python... the problem is the data is all
> stuck in C arrays.

> But how would I go about returning a python list of the entire array,
> or even better, an NumPy array?

there is a numpy.i file distributed with numpy ( or with the docs, 
anyway). There was also a recent post on the numpy list with some extra 
hints and examples for using it.

This is another nice article about it:

http://matt.eifelle.com/2008/11/04/exposing-an-array-interface-with-swig-for-a-cc-structure/

> My thoughts are that I will have to convert between C arrays and
> python types (list or NumPy) quite often, probably at a refresh rate
> suitable for animation.

the above allow a numpy array and your C-code to share the same pointer, 
so it is very fast.

-Chris

--

-- 
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker <at> noaa.gov

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
Rich E | 1 Dec 2008 20:49
Picon
Gravatar

Re: converting c float array to numpy array or python list

Someone earlier today in my office pointed me in the same direction,
so it looks like the way to go!  I'll give it a try.. . thanks
(especially for the article link).

cheers,
Rich

On Mon, Dec 1, 2008 at 8:43 PM, Christopher Barker
<Chris.Barker <at> noaa.gov> wrote:
> Rich E wrote:
>>
>> So I have a nice C library wrapped in python and I'd like to start
>> doing some plots of things in python... the problem is the data is all
>> stuck in C arrays.
>
>> But how would I go about returning a python list of the entire array,
>> or even better, an NumPy array?
>
> there is a numpy.i file distributed with numpy ( or with the docs, anyway).
> There was also a recent post on the numpy list with some extra hints and
> examples for using it.
>
> This is another nice article about it:
>
> http://matt.eifelle.com/2008/11/04/exposing-an-array-interface-with-swig-for-a-cc-structure/
>
>
>> My thoughts are that I will have to convert between C arrays and
>> python types (list or NumPy) quite often, probably at a refresh rate
>> suitable for animation.
>
> the above allow a numpy array and your C-code to share the same pointer, so
> it is very fast.
>
> -Chris
>
>
> --
> Christopher Barker, Ph.D.
> Oceanographer
>
> Emergency Response Division
> NOAA/NOS/OR&R            (206) 526-6959   voice
> 7600 Sand Point Way NE   (206) 526-6329   fax
> Seattle, WA  98115       (206) 526-6317   main reception
>
> Chris.Barker <at> noaa.gov
>

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
Sze Wan Lim | 2 Dec 2008 07:17
Picon

library for csharp

I have a C++ code to wrap into C#. But I dont seem to be able to use the list and iostream library.
 
I tried to do
%include "std_iostream.i"
%include "std_list.i"
 
But when i execute this I get error saying
Error: Unable to find ' std_iostream.i'
Error: Unable to find ' std_list.i'
I have checked into lib\std and both te files were there but they seem to be missing in lib\csharp.
 
So does this mean that there is no preprocess iostream and list library for csharp use? Anyone face this problem before? any work around for this?
 
Thanks!
 
SW
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Swig-user mailing list
Swig-user <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/swig-user
Domenico Mangieri | 2 Dec 2008 23:17
Favicon

c++ mangling

Hi
 
I'm wrapping c++ into c# using  visual c++ 2008.
 
For some reason when It creates the dll out of swig_wrap.cxx the functions get mangled even though in the auto generated file from swig they are all within   extern "C" { }
 
This makes C#  failing when loading the dll as the auto generated c# code uses the no mangled function names from swig_wrap.cxx
 
Anyone faced a similar problem ?
 
 
 
Attached is what dependency walker shows
 
and this is what present in the c# file
 
 
  [DllImport("WbWrappers", EntryPoint="CSharp_iTaskProgress_currentStatus")]
  [DllImport("WbWrappers", EntryPoint="CSharp_new_iTaskProgress")]
  [DllImport("WbWrappers", EntryPoint="CSharp_delete_iTaskProgress")]
  [DllImport("WbWrappers", EntryPoint="CSharp_iTaskProgress_director_connect")]
  [DllImport("WbWrappers", EntryPoint="CSharp_PluginManager_instance")]
  [DllImport("WbWrappers", EntryPoint="CSharp_PluginManager_getLibrary")]
  [DllImport("WbWrappers", EntryPoint="CSharp_PluginManager_ReadFileUsingPlugin__SWIG_0")]
  [DllImport("WbWrappers", EntryPoint="CSharp_PluginManager_ReadFileUsingPlugin__SWIG_1")]
  [DllImport("WbWrappers", EntryPoint="CSharp_new_PluginManager")]
  [DllImport("WbWrappers", EntryPoint="CSharp_delete_PluginManager")]
 
Domenico.
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Swig-user mailing list
Swig-user <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/swig-user
Ben Webb | 3 Dec 2008 03:03
Favicon

Bug in SWIG 1.3.35 with std::vector type system?

I have encountered a problem with SWIG 1.3.35 and later with a fairly
simple usage of std::vector. (I have opened a bug on the tracker
containing the same information, #2380788.) What seems to be happening
is that the SWIG runtime is getting confused about the type of the
std::vector.

For example, running 'make' with the following Makefile and test.i works
(produces no output from Python) with SWIG 1.3.34, but fails on SWIG
1.3.35, 1.3.36 and SVN r10960 with the error:
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "test.py", line 130, in insert
    def insert(self, *args): return _test.vectorf_insert(self, *args)
NotImplementedError: Wrong number of arguments for overloaded function
'vectorf_insert'.
  Possible C/C++ prototypes are:
    insert(std::vector< float > *,std::vector< float
>::iterator,std::vector< float >::value_type const &)
    insert(std::vector< float > *,std::vector< float
>::iterator,std::vector< float >::size_type,std::vector< float
>::value_type const &)

Obviously this makes STL vectors rather hard for us to use in practice!

I ran into the problem with Fedora 10's package of SWIG 1.3.35 (Fedora
9's build of 1.3.33 works just fine) but confirmed that it also fails
for me with 1.3.35 built from your upstream sources. (But ideally a
backport of any fix to 1.3.35 would be useful, so that Fedora can patch
their package without having to upgrade to an SVN snapshot.)

test.i:
%module test
%include "std_vector.i"
%template(vectorf) std::vector<float>;

Makefile:
SWIG=swig
test:
	${SWIG} -version
	${SWIG} -o test.cc -python -c++ test.i
	g++ -fPIC -I/usr/include/python2.5 -shared -o _test.so test.cc
	echo "import test; d = test.vectorf(); \
              d.insert(d.begin(), 1, 0.0)" | python

	Ben
--

-- 
ben <at> salilab.org                      http://salilab.org/~ben/
"It is a capital mistake to theorize before one has data."
	- Sir Arthur Conan Doyle

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
William S Fulton | 3 Dec 2008 23:34
Picon
Favicon
Gravatar

Re: c++ mangling

Domenico Mangieri wrote:
> Hi
>  
> I'm wrapping c++ into c# using  visual c++ 2008.
>  
> For some reason when It creates the dll out of swig_wrap.cxx the
> functions get mangled even though in the auto generated file from swig
> they are all within   extern "C" { }
>  
> This makes C#  failing when loading the dll as the auto generated c#
> code uses the no mangled function names from swig_wrap.cxx
>  
> Anyone faced a similar problem ?
>  
>  
The mangling is correct for extern C. You must be doing something else 
wrong to prevent it from loading, like not setting your path. I suggest 
you take one of the example solution files under Examples\csharp, build 
and run one of those and compare to see what you are doing wrong.

William

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/

Gmane