Hi,
have you considered Cython? I've used it already for some simple c to
python modules, and it is very easy to use..
Regards,
João Ventura
Em 15-12-2011 21:06, anatoly techtonik escreveu:
Can anybody help me? I am really stuck.
I can't understand why C++ was chosen to write the tool like Shiboken.
If it was in Python - it was much more easier to troubleshoot the
issues like this one.
--
anatoly t.
On Thu, Dec 15, 2011 at 1:55 AM, anatoly techtonik
<[email protected] <mailto:[email protected]>> wrote:
On Wed, Dec 14, 2011 at 11:38 PM, Hugo Parente Lima
<[email protected] <mailto:[email protected]>> wrote:
> > You also need to care care of putting all your includes
inside a "extern
> > C",
> > because shiboken generates C++ code.
> Could you, please, expand this a bit? Do I need to do this
in avbin.h file,
> or in generated .cpp/.h files?
When linking C code using a C++ compiler you must tell the C++
compiler that
the function is a C function, not a C++ function, you do this
putting the
function declaration inside a block like:
extern "C" {
}
Some C libraries already do that in their headers, but if your
library doesn't
do that you need to find a way to have all your C includes
inside a extern "C"
block.
I've wrapped code inside avbin.h into extern "C" block following
the excellent explanation from
http://www.parashift.com/c++-faq-lite/mixing-c-and-cpp.html but it still
doesn't help.
The problem is that Shiboken was meant to be used to wrap C++
code, not C, so
the code generator doesn't write the "extern C" before
including the library
headers and you need to find a way to do that. Thinking a bit
I don't know if
there's a clean way to do that with the current version of
Shiboken.
Do you mean that if I execute `shiboken lib/AVbin/include/avbin.h
typesystem.xml` shiboken can not detect if avbin.h is C or C++ header?
> > > For example, I want to create binding for
avbin_get_version() function
> > > available from
> > > https://github.com/AVbin/AVbin/blob/master/include/avbin.h
> > >
> > > I do:
> > > $ shiboken lib/AVbin/include/avbin.h typesystem.xml
> > >
> > > Where typesystem.xml is the following:
> > >
> > > <?xml version="1.0"?>
> > >
> > > <!-- the name of the module as it will be imported from
Python-->
> > > <typesystem package='AVbin'>
> > >
> > > <function signature='int avbin_get_version()'
rename='version'/>
> > >
> > > </typesystem>
> > >
> > >
> > > First of all it always complains about "No C++ classes
found!"
> >
> > You can ignore this message.
> >
> > > Then I see the message:
> > > Global function 'int avbin_get_version()' is specified
in typesystem,
> > > but not defined. This could potentially lead to
compilation errors.
> > >
> > > If I modify the <function> with
signature='avbin_get_version()' I get
> > >
> > > another error:
> > > skipping function '::avbin_get_version', unmatched
return type 'int'
> >
> > Probably this function wasn't found in your global header,
the header
> > file read by shiboken to find what classes/function can be
bound, look
> > at the log
> > files generated by the generator.
>
> They are empty. 1032 bytes each.
> Console output: http://pastebin.com/fU7rzmXi
> Generated files:
> - out/AVbin/avbin_module_wrapper.cpp -
http://pastebin.com/GUkTiksN
> - out/AVbin/avbin_python.h - http://pastebin.com/KmGDW8xi
No, I meant the log files created by the generator, something like
mjb_rejected_functions.log, the log must explain why the
functions were
rejected.
All logs look the same: http://paste.kde.org/159104/
I've specified --debug-level=full but it added only one line to
console output that doesn't explain anything:
DEBUG :: Parsed: 'typesystem.xml', 2 new entries
> I've uploaded the project to:
> https://bitbucket.org/techtonik/shiboken-avbin
_______________________________________________
PySide mailing list
[email protected]
http://lists.pyside.org/listinfo/pyside
_______________________________________________
PySide mailing list
[email protected]
http://lists.pyside.org/listinfo/pyside