| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
|
|
|
|
|
| |
Not for binded types implementing sequence protocol, otherwise this will
cause a mess like QBitArray being accepted by someone expecting a
QStringList.
|
|
|
|
| |
templates.
|
|
|
|
|
|
|
| |
null pointer.
Pro: Will be possible to write template functions to handle sequence conversions.
Cons: We will not have an unresolved symbol when an error occur on generator.
|
| |
|
|
|
|
|
|
|
|
|
| |
The new semantic is:
Returns true when the type can be converted to T OR the type is T.
The old semantic was:
Returns true when the type can be converted to T and false if the
type is T, however int and float converters did not follow this
rule, because they used PyNumber_Check on their isConvertible implementation.
|
| |
|
| |
|
|\
| |
| |
| |
| |
| |
| |
| |
| | |
Conflicts:
cppgenerator.cpp
libshiboken/basewrapper.cpp
Reviewed by Hugo Parente <hugo.lima@openbossa.org>
Reviewed by Lauro Moura <lauro.neto@openbossa.org>
|
| |\
| | |
| | |
| | |
| | | |
Conflicts:
libshiboken/conversions.h
|
| | | |
|
|/ /
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Value type classes without implicit conversions use the default
implementation provided by ValueTypeConverter. This commit updates
ValueTypeConverter to check for extended conversions, since even a
class without implicit conversions in one module could get some
conversion operators in another.
CppGenerator now writes 'isConvertible' calls to all object and
value types checks leaving the door open to extended conversions.
|
|/
|
|
|
|
|
|
|
|
|
|
| |
To improve legibility and understanding ConverterBase<T> was renamed
to ValueTypeConverter<T>, and ConverterBase<T*> specialization is
now an independent base converter ObjectTypeConverter<T>.
Converter_CppEnum was renamed to EnumConverter.
The HeaderGenerator and custom converters for the test bindings were
updated accordingly.
Reviewed by Hugo Parente <hugo.lima@openbossa.org>
Reviewed by Lauro Moura <lauro.neto@openbossa.org>
|
|
|
|
|
|
| |
conventions.
Reviewed by Marcelo Lira <marcelo.lira@openbossa.org>
|
|
|
|
| |
field in SbkBaseWrapper_Type.
|
|
|
|
| |
expressions.
|
|
|
|
|
| |
The conversion of '[const] char*' to C++ now accepts an None object
and gives back a NULL pointer.
|
|
|
|
| |
Reviewed by Marcelo Lira <marcelo.lira@openbossa.org>
|
|
|
|
| |
instanciations.
|
|
|
|
|
|
| |
Only if not specified signed/unsigned
Reviewer: Marcelo Lira <marcelo.lira@openbossa.org>
|
|
|
|
|
|
|
|
|
| |
A new converter specialization was added to deal with 'void*'
conversions. In the case of C++ generating a unknown void pointer
a BaseWrapper is used to hold the said pointer.
There is a new test for this situation.
Reviewed by Renato Araújo <renato.filho@openbossa.org>
|
| |
|
| |
|
|
|
|
|
|
| |
A type is convertible to char if it is a number or a 1-sized char.
Reviewed by Marcelo Lira <marcelo.lira@openbossa.org>
|
|
|
|
|
| |
- Converter<PyInt>::isConvertible should return bool instead of int and
- Converter<PyInt>::toPython must receive "const PyInt&" instead of just "PyInt".
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The problem:
- There are two class, A and B, B inherits from A.
- You are inside a virtual method reimplemented in python with just one parameter of type A*.
- But the object referenced by a variable of type A* is an instance of B and it was created by C++,
not Python!
- Shiboken needs to create a PyObject of type B, not A! This does not makes sense for C++, but does
for Python, because python variables does not store type information, just values.
To achieve this we use RTTI to get the real type name of a variable, then we create the PyObject using
the TypeResolver infrastructure initially developed to help with signal slot problems. In other words,
the TypeResolver class has been moved from libpyside to libshiboken.
|
|
|
|
| |
Reviewed by Marcelo Lira <marcelo.lira@openbossa.org>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
template struct
In addition to the mere use of SbkCopyCppObject to copy C++ objects,
it is needed to know if a C++ type has a C++ wrapped produced by the
generator. To solve this SbkCopyCppObject was transformed in the template
struct CppObjectCopier with the methods copy and the constant member
isCppWrapper.
The Converter[Base]<>::createWrapper methods were replaced by template
function SbkCreateWrapper.
Also some refactoring was made on the Converters code to improve legibility.
Reviewed by Hugo Parente <hugo.lima@openbossa.org>
|
|
|
|
|
|
|
| |
Short methods in Converter and ConverterBase variations received the
"inline" keyword.
A convenience "toPython" signature receiving "void*" as parameter was
also added to the converter classes.
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
Added a test for simple implicit numerical conversions involving
doubles, signed and unsigned ints and longs.
Some fixes to the converters were also made, mostly related to
adding manual checks for boundaries with doubles for negative values
Also put the overflow check in a single template
Reviewer: Marcelo Lira <marcelo.lira@openbossa.org>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
SbkBaseWrapperType.
The wrapped classes are described with a SbkBaseWrapperType structure which
extends the PyTypeObject with information about multiple inheritance and
parenting ownership. This works well for the classes produced by the generator
but inheriting classes written in Python continues using the PyTypeObject to
describe themselves. To fix this the SbkBaseWrapperType is now a metatype for
all the wrapped classes and anyone inheriting from them.
In addition all the wrapped classes now inherit from SbkBaseWrapper, since
Python's PyType_Ready method need that multiple inheriting classes have a
common base class with the same size of the classes involved in the multiple
inheritance, which disqualifies Python's base "object" class.
The metatype and the base wrapper type are initialized by calling the new
Shiboken::init_shiboken() function. This is done by all the imported binding
modules, but it is really run only in the first call.
Another noteworthy change is the replacement of PyTypeObject as a basis for
SbkBaseWrapperType by the PyHeapTypeObject, since the latter is the proper
choice for types created on the heap, e.g. user defined classes extending
the generated wrapper classes.
Reviewed by Hugo Lima <hugo.lima@openbossa.org>
|
|
|
|
| |
with SbkBaseWrapper.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Added the template function
T* SbkCopyCppObject(const T& cppobj);
whose task is simply to copy a C++ object. If the binding has a C++ class
wrapper for it, the function is specialized to use the copy constructor
of the C++ wrapper class. This replaces the Converter<T>::copyCppObject
method.
Also moved implementation of Converter<T>::toPython from the generator to
ConverterBase<T> in the conversions header, for it makes use of the
SbkCopyCppObject.
Reviewed by Lauro Neto <lauro.neto@openbossa.org>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
To avoid confusion of Python stuff with Shiboken generated stuff.
For example: a C++ class called "String" would have the PyString_Type
wrapper generated for it, mixing with the proper Python PyString_Type;
now the generate code will have things like SbkString_Type, SbkString_New,
SbkString_someMethod, and so on.
PyBaseWrapper and its variants were renamed to SbkBaseWrapper.
PyType<T>() is now SbkType<T>()
PyEnumObject was renamed to SbkEnumObject.
|
|
|
|
|
|
|
| |
The implementation of converters for pair, list and map containers was
moved from libsample test binding to libshiboken/conversions.h. The
implementation must be used with types similar to the C++ STL containers
of the same name.
|
|
|
|
|
|
|
|
|
|
|
| |
The Shiboken_TypeCheck calls Python's PyObject_TypeCheck using the
type pointer stored in PyType<T> for the type being checked.
Conversion<T*>::toCpp(pyobj) converter tries first to convert pyobj
to the Python wrapper for type T and only second to any of the
convertible types. If pyobj is neither of those, 0 is returned as
the C++ object. This works fine for Py_None and invalid values are
not expected to be passed because the generated code checked the
types first.
|
|
|
|
|
|
|
| |
auto generated by the compiler using the function PyType<T> to get
PyTypeObject of a type T.
Reviewed by Marcelo Lira <marcelo.lira@openbossa.org>
|
|
|
|
|
|
| |
Unit tests were added also.
Reviewed by Hugo Lima <hugo.lima@openbossa.org>
|
|
|
|
| |
Reviewed by Marcelo Lira <marcelo.lira@openbossa.org>
|
|
|
|
| |
pointer.
|
|
|
|
|
|
|
|
|
|
|
|
| |
It sets the wrapper as invalid and removes the relation of C++ objects
to the Python wrapper from the mappings.
Moved BindingManager::releaseWrapper(void*) to BindingManagerPrivate,
since it should only be used by releaseWrapper(PyObject*).
Modified includes on conversions.h to use quotes instead of < and >.
Reviewed by Hugo Lima <hugo.lima@openbossa.org>
|
|
|
|
|
|
|
| |
avoid problems when converting PyObjects to C++.
Tests where also added for this.
Reviewed by Lauro Neto <lauro.neto@openbossa.org>
|
|
|
|
|
|
|
| |
the generator writes type checks as TYPENAME_Check, so this macro allows
users to add PyObject arguments to their added functions.
Reviewed by Marcelo Lira <marcelo.lira@openbossa.org>
|
|
|
|
|
| |
is received.
Fixed and improved the test for functions returning NULL pointer values.
|
|
|
|
| |
NULL.
|
|
|
|
| |
Reviewed by Hugo Lima (hugo.lima@openbossa.org)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
ConverterBase from which the generic Converter<T> and the specific
Converters inherit; two methods were added:
* createWrapper: returns a new PyObject wrapper with the Python type
information produced by the HeaderGenerator; this method is called
by toPython when a not yet wrapped C++ object needs to be converted.
* copyCppObject: copies a instance of a C++ class, usually created by
a implicit conversion that needs to be passed to a C++ methods;
could be more than one method with variants of the converted type
(value, reference, pointer) that makes no difference to the Python
wrapped class.
The C++ arguments converted from Python arguments by the Python method
wrapper are dealt with as pointers if they are object or value types.
Abstract classes and object-types, whose copy constructor and operator=
should be private, are declared as Converter<T*> instead of Converter<T>
and inherit from ConverterBase<T*>, this avoids impossible tries to copy
such objects.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
from libshiboken, other changes followed this improvement:
* added a Converter<T*> specialization that inherits from Converter<T>; its
toPython(const T* cppobj) method returns a existing Python wrapper and
increments its refcount, or else it creates a new wrapper using the
createWrapper method. Now createWrapper is the only method generated for
Object Type conversions.
* added a Converter<T&> specialization that inherits from Converter<T*> and
just calls its parent's methods adapting them to C++ references.
* added a base template class for C++ enums and flags conversions called
Converter_CppEnum, it inherits from the base Conversion class. Now the
HeaderGenerator need only to generate the Converter<ENUM>::createWrapper method.
* all generated conversions now uses only the type name and no qualifiers (i.e.
Object Type converters are declared Converter<TYPE> instead of Converter<TYPE*>
|