A comment in service/iservice.h is all I have to go on:
Here's a small example of how it's done:some words to structs like struct iServiceInformation_ENUMS
For some classes we need in python just the SmartPointer Variants.
So we prevent building wrapper classes for the non smart pointer classes with the SWIG_IGNORE makro.
But now we have the problem that swig do not export enums for smart pointer classes (i dont know why).
So we move all enum's to own classes (with _ENUMS as name ending) and let our real
class inherit from the *_ENUMS class. This *_ENUMS classes are normally exportet via swig to python.
But in the python code we doesn't like to write iServiceInformation_ENUMS.sVideoType....
we like to write iServiceInformation.sVideoType.
So until swig have no Solution for this Problem we call in lib/python/Makefile.am a python script named
enigma_py_patcher.py to remove the "_ENUMS" strings in enigma.py at all needed locations.
Code: Select all
// in swig.h
#define SWIG_IGNORE(x) %ignore x
#define SWIG_TEMPLATE_TYPEDEF(x, y) %template(y) x; %typemap_output_ptr(x)
// in service/iservice.h
class iCueSheet_ENUMS
{
#ifdef SWIG
iCueSheet_ENUMS();
~iCueSheet_ENUMS();
#endif
public:
enum { cutIn = 0, cutOut = 1, cutMark = 2 };
};
SWIG_IGNORE(iCueSheet);
class iCueSheet: public iCueSheet_ENUMS, public iObject
{
#ifdef SWIG
iCueSheet();
~iCueSheet();
#endif
public:
/* returns a list of (pts, what)-tuples */
virtual PyObject *getCutList() = 0;
virtual void setCutList(SWIG_PYOBJECT(ePyObject) list) = 0;
virtual void setCutListEnable(int enable) = 0;
};
SWIG_TEMPLATE_TYPEDEF(ePtr<iCueSheet>, iCueSheetPtr);
Code: Select all
class iCueSheet(object):
...
cutIn = _enigma.iCueSheet_ENUMS_cutIn
cutOut = _enigma.iCueSheet_ENUMS_cutOut
cutMark = _enigma.iCueSheet_ENUMS_cutMark
Code: Select all
SWIG_IGNORE(eServiceEvent);
class eServiceEvent: public iObject
{
DECLARE_REF(eServiceEvent);
static std::string crid_scheme;
...
};
SWIG_TEMPLATE_TYPEDEF(ePtr<eServiceEvent>, eServiceEvent);
SWIG_EXTEND(ePtr<eServiceEvent>,
static void setEPGLanguage(const std::string& language)
{
eServiceEvent::setEPGLanguage(language);
}
);
SWIG_EXTEND(ePtr<eServiceEvent>,
static void setEPGLanguageAlternative(const std::string& language)
{
eServiceEvent::setEPGLanguageAlternative(language);
}
);
SWIG_TEMPLATE_TYPEDEF(ePtr<iCueSheet>, iCueSheetPtr)
(the second argument has "Ptr" added to the class name, while in the eServiceEvent case, the same class name is used:
SWIG_TEMPLATE_TYPEDEF(ePtr<eServiceEvent>, eServiceEvent).
That means that if I try to do a similar thing with enums to the iCueSheet case:
Code: Select all
struct eServiceEvent_ENUMS
{
public:
// CRID matches are for all CRIDs of that class:
// SERIES_MATCH matches both SERIES and SERIES_AU
enum {
SERIES_MATCH = 1 << eCridData::SERIES,
EPISODE_MATCH = 1 << eCridData::EPISODE,
RECOMMENDATION_MATCH = 1 << eCridData::RECOMMENDATION,
ALL_MATCH = SERIES_MATCH | EPISODE_MATCH | RECOMMENDATION_MATCH,
};
};
SWIG_IGNORE(eServiceEvent);
class eServiceEvent: public eServiceEvent_ENUMS, public iObject
{
DECLARE_REF(eServiceEvent);
...
};
SWIG_TEMPLATE_TYPEDEF(ePtr<eServiceEvent>, eServiceEvent);
SWIG_EXTEND(ePtr<eServiceEvent>,
static void setEPGLanguage(const std::string& language)
{
eServiceEvent::setEPGLanguage(language);
}
);
SWIG_EXTEND(ePtr<eServiceEvent>,
static void setEPGLanguageAlternative(const std::string& language)
{
eServiceEvent::setEPGLanguageAlternative(language);
}
);
Code: Select all
class eServiceEvent(object):
...
SERIES_MATCH = _enigma.eServiceEvent_ENUMS_SERIES_MATCH
EPISODE_MATCH = _enigma.eServiceEvent_ENUMS_EPISODE_MATCH
RECOMMENDATION_MATCH = _enigma.eServiceEvent_ENUMS_RECOMMENDATION_MATCH
ALL_MATCH = _enigma.eServiceEvent_ENUMS_ALL_MATCH
...
class eServiceEvent(object):
...
# no definitions of the *_MATCH constants.
...