library of assembled shared sources

http://lass.cocamware.com

pyshadow_object.h File Reference

#include "pyobject_plus.h"
#include "../meta/is_derived.h"
#include <set>

Include dependency graph for pyshadow_object.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.


Data Structures

class  lass::python::impl::PyShadowBaseCommon
class  lass::python::impl::PyShadowBaseTracked< CppBase >
class  lass::python::impl::PyShadowBaseTracked< CppBase >::AutomaticObjectInvalidator
class  lass::python::impl::PyShadowBase< CppBase, weak >
struct  lass::python::ShadowObjectInvalidator< CppBase >
struct  lass::python::impl::PyShadowBaseWeak< CppBase >
 a weak shadow class NEVER EVER owns the object, USE AT YOUR OWN RISK! Consult your local Lass::Python guru to gain insight when the use of this class is appropriate. More...
struct  lass::python::impl::IsShadowClass< T >
struct  lass::python::impl::ShadowTraits< T >
struct  lass::python::impl::ShadowTraits< T >::Impl< U, shadow >
struct  lass::python::impl::ShadowTraits< T >::Impl< U, false >

Namespaces

namespace  lass
 Library for Assembled Shared Sources.
namespace  lass::python
namespace  lass::python::impl

Defines

#define PY_SHADOW_CLASS_EX(dllInterface, i_PyObjectShadowClass, t_CppClass, t_PyObjectBase, t_PyObjectParent)
#define PY_SHADOW_CLASS_NOCONSTRUCTOR_EX(dllInterface, i_PyObjectShadowClass, t_CppClass, t_PyObjectBase, t_PyObjectParent)
#define PY_SHADOW_CLASS(dllInterface, i_PyObjectShadowClass, t_CppClass)
#define PY_SHADOW_CLASS_NOCONSTRUCTOR(dllInterface, i_PyObjectShadowClass, t_CppClass)
#define PY_WEAK_SHADOW_CLASS(dllInterface, i_PyObjectShadowClass, t_CppClass)
 a weak shadow class NEVER EVER owns the object, USE AT YOUR OWN RISK! Consult your local Lass::Python guru to gain insight when the use of this class is appropriate.
#define PY_WEAK_SHADOW_CLASS_NOCONSTRUCTOR(dllInterface, i_PyObjectShadowClass, t_CppClass)
#define PY_SHADOW_CLASS_ENABLE_AUTOMATIC_INVALIDATION(i_PyObjectShadowClass)   i_PyObjectShadowClass::doTracking = true;
 a macro to enable automatic invalidation for a given shadow class
#define PY_SHADOW_CLASS_DERIVED(dllInterface, i_PyObjectShadowClass, t_CppClass, t_PyObjectShadowParent)
#define PY_SHADOW_CLASS_DERIVED_NOCONSTRUCTOR(dllInterface, i_PyObjectShadowClass, t_CppClass, t_PyObjectShadowParent)
#define PY_CLASS_CONSTRUCTOR_BYCOPY_IMPL(t_ShadowObject)
 a macro that enables shadow classes to have conversion (coercion) operations defined on construction Say you have following situation: class A { A(int a) {} }; class B { B(const A& iA) {} }; You may whish to create an object B with int as constructor argument, without having proper custom pyGetSimpleObject this will not work unless you use the PY_CLASS_CONVERTOR macro to let the conversion routines know which possibilities may be tried before giving up and throwing a not-casteable exception.
#define PY_SHADOW_CASTERS(t_ShadowObject)
#define PY_SHADOW_DOWN_CASTERS(t_ShadowObject)
#define PY_SHADOW_DOWN_CASTERS_NOCONSTRUCTOR(t_ShadowObject)
#define PY_CLASS_CONVERTOR(t_ShadowObject,i_conversionFunction)   lass::python::impl::ShadowTraits< t_ShadowObject >::byCopyGetters.push_back( & i_conversionFunction );

Functions

template<typename CppBase >
void lass::python::invalidateShadowingObject (CppBase *iPointerReferenceToInvalidate)


Detailed Description

Author:
Bram de Greve (bramz@users.sourceforge.net)

Tom De Muer (tomdemuer@users.sourceforge.net)

Distributed under the terms of the GPL (GNU Public License)

The LASS License:

Copyright 2004-2008 Bram de Greve and Tom De Muer

LASS is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

Note:
This header bundles the _EXPERIMENTAL_ code for quasi automatic wrapping of C++ object hierarchies into python shadow objects. This code is still heavily under development and not ready for production use.

Definition in file pyshadow_object.h.


Define Documentation

#define PY_SHADOW_CLASS_EX ( dllInterface,
i_PyObjectShadowClass,
t_CppClass,
t_PyObjectBase,
t_PyObjectParent   ) 

Definition at line 281 of file pyshadow_object.h.

#define PY_SHADOW_CLASS_NOCONSTRUCTOR_EX ( dllInterface,
i_PyObjectShadowClass,
t_CppClass,
t_PyObjectBase,
t_PyObjectParent   ) 

Definition at line 316 of file pyshadow_object.h.

#define PY_SHADOW_CLASS ( dllInterface,
i_PyObjectShadowClass,
t_CppClass   ) 

Value:

Definition at line 350 of file pyshadow_object.h.

#define PY_SHADOW_CLASS_NOCONSTRUCTOR ( dllInterface,
i_PyObjectShadowClass,
t_CppClass   ) 

Value:

Definition at line 355 of file pyshadow_object.h.

#define PY_WEAK_SHADOW_CLASS ( dllInterface,
i_PyObjectShadowClass,
t_CppClass   ) 

Value:

a weak shadow class NEVER EVER owns the object, USE AT YOUR OWN RISK! Consult your local Lass::Python guru to gain insight when the use of this class is appropriate.

A rule of thumb is that any properly designed C++ interface should never be exposed using weak shadow objects.

Definition at line 366 of file pyshadow_object.h.

#define PY_WEAK_SHADOW_CLASS_NOCONSTRUCTOR ( dllInterface,
i_PyObjectShadowClass,
t_CppClass   ) 

Value:

Definition at line 371 of file pyshadow_object.h.

#define PY_SHADOW_CLASS_ENABLE_AUTOMATIC_INVALIDATION ( i_PyObjectShadowClass   )     i_PyObjectShadowClass::doTracking = true;

a macro to enable automatic invalidation for a given shadow class

Definition at line 378 of file pyshadow_object.h.

#define PY_SHADOW_CLASS_DERIVED ( dllInterface,
i_PyObjectShadowClass,
t_CppClass,
t_PyObjectShadowParent   ) 

Value:

PY_SHADOW_CLASS_EX(\
        dllInterface, i_PyObjectShadowClass, t_CppClass, t_PyObjectShadowParent, t_PyObjectShadowParent)

Definition at line 381 of file pyshadow_object.h.

#define PY_SHADOW_CLASS_DERIVED_NOCONSTRUCTOR ( dllInterface,
i_PyObjectShadowClass,
t_CppClass,
t_PyObjectShadowParent   ) 

Value:

PY_SHADOW_CLASS_NOCONSTRUCTOR_EX(\
        dllInterface, i_PyObjectShadowClass, t_CppClass, t_PyObjectShadowParent, t_PyObjectShadowParent)

Definition at line 385 of file pyshadow_object.h.

#define PY_CLASS_CONSTRUCTOR_BYCOPY_IMPL ( t_ShadowObject   ) 

Value:

inline int pyGetSimpleObject(PyObject* iValue, lass::util::SharedPtr<t_ShadowObject, lass::python::PyObjectStorage, lass::python::PyObjectCounter>& oV)\
{\
    const bool isNone = (iValue == Py_None );\
    if (isNone)\
        oV = lass::util::SharedPtr< t_ShadowObject, lass::python::PyObjectStorage, lass::python::PyObjectCounter>();\
    else\
    {\
        if (!PyType_IsSubtype(iValue->ob_type , & t_ShadowObject::_lassPyType ))\
        {\
            for (size_t i=0;i<lass::python::impl::ShadowTraits< t_ShadowObject >::byCopyGetters.size();++i)\
            {\
                lass::python::impl::ShadowTraits< t_ShadowObject >::TCppClass* newCopy = new lass::python::impl::ShadowTraits< t_ShadowObject >::TCppClass();\
                if (!lass::python::impl::ShadowTraits< t_ShadowObject >::byCopyGetters[i](iValue, *newCopy))\
                {\
                    typedef lass::util::SharedPtr<t_ShadowObject, lass::python::PyObjectStorage, lass::python::PyObjectCounter> TSharedPtr;\
                    TSharedPtr newOv(new t_ShadowObject (newCopy));\
                    oV.swap(newOv);\
                    PyErr_Clear();\
                    return 0;\
                }\
            }\
            PyErr_Format(PyExc_TypeError,"not castable to %s", t_ShadowObject::_lassPyType.tp_name);\
            return 1;\
        }\
        oV = lass::python::fromNakedToSharedPtrCast< t_ShadowObject >(iValue);\
    }\
    return 0;\
}
a macro that enables shadow classes to have conversion (coercion) operations defined on construction Say you have following situation: class A { A(int a) {} }; class B { B(const A& iA) {} }; You may whish to create an object B with int as constructor argument, without having proper custom pyGetSimpleObject this will not work unless you use the PY_CLASS_CONVERTOR macro to let the conversion routines know which possibilities may be tried before giving up and throwing a not-casteable exception.

Definition at line 406 of file pyshadow_object.h.

#define PY_SHADOW_CASTERS ( t_ShadowObject   ) 

Definition at line 437 of file pyshadow_object.h.

#define PY_SHADOW_DOWN_CASTERS ( t_ShadowObject   ) 

Definition at line 569 of file pyshadow_object.h.

#define PY_SHADOW_DOWN_CASTERS_NOCONSTRUCTOR ( t_ShadowObject   ) 

Definition at line 778 of file pyshadow_object.h.

#define PY_CLASS_CONVERTOR ( t_ShadowObject,
i_conversionFunction   )     lass::python::impl::ShadowTraits< t_ShadowObject >::byCopyGetters.push_back( & i_conversionFunction );

Definition at line 955 of file pyshadow_object.h.


Generated on Mon Nov 10 14:22:05 2008 for Library of Assembled Shared Sources by doxygen 1.5.7.1
SourceForge.net Logo