Jacob Bower | 1 Feb 2007 06:08
Picon

TCL and automated object freeing

Hi,

Looking at the code generated by swig 1.3 for TCL, it would appear
that Tcl_Obj's created with SWIG_Tcl_NewPointerObj() won't be free'd
when the refcount of the Tcl_Obj falls to zero. Is this correct?

If so, is there a graceful way of automating the freeing of objects
passed through SWIG_Tcl_NewPointerObj() when the TCL script no longer
has a reference to them (ignoring circular ref's etc.) which doesn't
involve having to manually free objects with calls from TCL?

Thanks
- Jacob

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier.
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
William S Fulton | 2 Feb 2007 00:12
Picon
Favicon
Gravatar

Re: %delobject and Java

Bob Marinier wrote:
> I recently discovered a case in our code where it looks like we need to 
> use %delobject on one of our methods.  However, there does not appear to 
> be any change in the generated C++ or Java code (indeed, things still 
> crash for us).  Is %delobject implemented for Java?
> 
> Just to see if, in principle, this change would work, we hand-modified 
> the generated Java code to set swigCMemOwn flag of the parameter to the 
> method to false, and this does indeed fix our problem.  If %delobject is 
> not implemented for Java, is there a way to automatically insert this 
> code in the beginning of the generated Java code for this method?  I 
> suppose I could rename the generated method and create a wrapper method 
> with the original name that sets this flag and then calls the renamed 
> method, but being able to insert code directly into the generated Java 
> would be cleaner.
> 

There is no DISOWN typemap for Java, so %delobject won't work as it
requires these typemaps. Instead you can modify the code through the
javain typemap. See the documentation in Java.html about memory
management, there are some examples too.

William

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier.
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
(Continue reading)

William S Fulton | 2 Feb 2007 00:12
Picon
Favicon
Gravatar

Re: swig for python produces 'long long illegal' on win xp

David Beazley wrote:
> On Jan 31, 2007, at 9:28 AM, Kurien Mathew wrote:
> 
>> Actually swig has some typemaps/%apply that should map "long long" to
>> "__int64" on windows. eg In windows.i
>>
>> %apply long long { __int64 };
>> %apply const long long& { const __int64& };
>>
>> But this did not seem to avoid "long long" in the wrapper code that  
>> was
>> generated.
> 
> No, because the use of "long long" is probably coming from the header  
> file you're trying to wrap, not SWIG. I would check the header to see  
> if there are any macros or defines related to the use of long long.   
> If so, I'd make sure those macros are also defined when running  
> SWIG.  That way, SWIG and the C++ compiler are at least seeing the  
> code in the same way.
> 

Actually SWIG now generates helper functions that use 'long long' which
means that it won't compile with VC++ 6. In older versions of SWIG it
was possible to apply the long long typemaps to __int64. This was before
the typemaps that SWIG supply started using helper functions. If you use
swig-1.3.21, the generated code will compile under vc++ 6:

%apply long long {__int64};

%inline %{
(Continue reading)

Collin Lynch | 2 Feb 2007 12:32
Picon

[cffi] Clos issues and Exceptions.

When running swig 1.3.31 using "-c++ -cffi" I encountered three issues.

1) Clos wrapper has excess arguments.
The clos wrapper generated by my code is producing extra arguments.  That
is, given a c++ method that takes only the member as an argument the
system generates a viable wrapper but the clos wrapper has an excess
argument. e.g.:

  CardSuit getSuit(void);

(cffi:defcfun ("_wrap_Card_getSuit" Card_getSuit) :int
  (self :pointer))

(clos:defmethod get-suit ((obj card) (self card))
  (Card_getSuit (ff-pointer obj) (ff-pointer self)))

As you can see the defcfun matches the C++ signature (and works at
runtime) however the defmethod expects an extra argument (for no apparent
reason) and attempts to pass that on to the lower-level cfun incorrectly.
This raises a too-many-arguments error.

2) Constants.
Again the .lisp file defines constants and cvars for the members of the
file:

(cl:defconstant CARDDEFS "DEFS")

(cffi:defcvar ("BLACKNONE" BLACKNONE)
 :int)

(Continue reading)

Stefan Bellon | 2 Feb 2007 12:49

Problem with Python wrapper code in SWIG_InitializeModule

Hi!

We have trouble with the C wrapper code in SWIG_InitializeModule that
is generated for interfacing with Python with SWIG version 1.3.31. It
worked fine in 1.3.29.

Our case is a bit special as we do not keep the _name.so files
separate, but link them directly into the binary (or in our case a
plugin library) where we call the appropriate SWIG_init function after
the Python interpreter was started with Py_Initialize. The interpreter
is started for several tasks in a sequence. This setup works fine with
the SWIG_InitializeModule code that SWIG 1.3.29 generates:

SWIGRUNTIME void
SWIG_InitializeModule(void *clientdata) {
  size_t i;
  swig_module_info *module_head;
  static int init_run = 0;

  clientdata = clientdata;

  if (init_run) return;
  init_run = 1;

  /* Initialize the swig_module */
  swig_module.type_initial = swig_type_initial;
  swig_module.cast_initial = swig_cast_initial;

  /* Try and load any already created modules */
  module_head = SWIG_GetModule(clientdata);
(Continue reading)

innomedia | 2 Feb 2007 16:04

Problem with loading libraries


Hi all,
            We r using apache 2.4 with php-5.2.0 and swig1.3.31.

             we had created  example.so example.o files by compling
example.c and iterface file with example.i

              when we try to call the function which we defined in c from
php we r facing the following problem 

             PHP Warning:  dl(): Unable to load dynamic library
'/usr/lib/php/modules/example.so' - /usr/lib/php/modules/example.so:
undefined symbol: my_mod in
/usr/local/php/include/php/home/choisos/php-5.2.0/Today/example.php on line
23

--

-- 
View this message in context: http://www.nabble.com/Problem-with-loading-libraries-tf3161277.html#a8768444
Sent from the swig-user mailing list archive at Nabble.com.

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier.
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
Jacob Bower | 2 Feb 2007 19:10
Picon

Re: TCL and automated object freeing

Okay I think I solved this problem myself. It seesm that if I want the
object to be managed for me I should use SWIG_Tcl_NewInstanceObj
instead.

On 1/31/07, Jacob Bower <jacob.bower <at> gmail.com> wrote:
> Hi,
>
> Looking at the code generated by swig 1.3 for TCL, it would appear
> that Tcl_Obj's created with SWIG_Tcl_NewPointerObj() won't be free'd
> when the refcount of the Tcl_Obj falls to zero. Is this correct?
>
> If so, is there a graceful way of automating the freeing of objects
> passed through SWIG_Tcl_NewPointerObj() when the TCL script no longer
> has a reference to them (ignoring circular ref's etc.) which doesn't
> involve having to manually free objects with calls from TCL?
>
> Thanks
> - Jacob
>

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier.
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
Chris Gurtler | 2 Feb 2007 21:24

Callback functions

Hi All,

I have a question regarding callback functions. I tried the Java 
callback example and this will call the callback from within "main" and 
it executes the callback quite nicely. In my application I want the 
callback to be fired from the "C" code which is operating in another 
thread than "main". I wrote a test application for this and I could not 
see the output from the println statement. The source looks a little 
like the code snippet below. Can anyone tell me if this should be 
possible? Will it be thread safe?

class Caller {
private:
    Callback *_callback;
    void worker_thread()
    {
          //Start a new thread and fire callback
     }
public:
    Caller(): _callback(0) {worker_thread();}
    ~Caller() { delCallback(); }
    void delCallback() { delete _callback; _callback = 0; }
    void setCallback(Callback *cb) { delCallback(); _callback = cb; }
    void call() { if (_callback) _callback->run(); }
};

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier.
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
(Continue reading)

Kassim Machioudi | 3 Feb 2007 20:42

SWIG & PHP

All,

I am new to SWIG and would like to get a simple example running, but 
without success. I get the error below:

example_wrap.obj : error LNK2019: unresolved external symbol 
__imp__compiler_globals referenced in function _zm_startup_example

while running this command:

link /nologo /dll /machine:I386 -out:D:\dev\Swig\test\php_example.dll  
.\example.obj  .\example_wrap.obj user32.lib         gdi32.lib        
 comdlg32.lib     comctl32.lib     shell32.lib         ole32.lib         
 oleaut32.lib      winmm.lib         advapi32.lib     php5ts.lib

Any clues about how to solve this issue?

Thanks,

--
Kassim

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier.
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
Matthew Bromberg | 4 Feb 2007 01:33
Picon
Favicon

Fundamental DLL limitation

I've been a happy user of swig for a while.  However recently I've tried 
to use swig to interface a dll
to a convenient scripting language (I tried python and tcl.) and have 
run into problems.  The dll contains several functions that use the
standard call protocol and it also has an MS VC++ compatible library 
(.lib) stub.

The functions, however, were not generated from C or C++ code.  Let's 
say for example that I call the project
test and I have a few simple C style function prototypes in test.h.  The 
library we'll call lib.dll and lib.lib.  I create
an interface file test.i that simply includes test.h to create 
test_wrap.c.  Now how do I create the interface dll for say tcl?

One might naively try from the command line using MS VC++ 7.0 (actually 
the 2003 toolkit):

cl.exe $(TCL_Inc) /D__WIN32__ /LD test_wrap.c lib.lib 
$(TCL_libpath)\tcl84.lib  /link /OUT:test.dll

But this creates a dll with the symbols
Test_Init
Test_SafeInit

but does not contain any of the symbols in the original dll test.dll.  
When the dll is loaded into tcl, none of lib.dll's routines are visible.
(For the python case, the dll doesn't load at all.)   So it appears that 
one has to create a .def file and try to export the symbols to
test.dll.  Unfortunately in my case, test.dll has two symbols for each 
routine, a decorated and undecorated symbol.  This seems to cause 
(Continue reading)


Gmane