本文整理汇总了C++中PythonWrapper::wrapper方法的典型用法代码示例。如果您正苦于以下问题:C++ PythonWrapper::wrapper方法的具体用法?C++ PythonWrapper::wrapper怎么用?C++ PythonWrapper::wrapper使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PythonWrapper
的用法示例。
在下文中一共展示了PythonWrapper::wrapper方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: wrapEntity
PyObject * wrapEntity(LocatedEntity * le)
{
PyObject * wrapper;
PythonWrapper * pw = dynamic_cast<PythonWrapper *>(le->script());
if (pw == 0) {
Entity * entity = dynamic_cast<Entity *>(le);
if (entity != 0) {
Character * ch_entity = dynamic_cast<Character *>(entity);
if (ch_entity != 0) {
PyEntity * pc = newPyCharacter();
if (pc == NULL) {
return NULL;
}
pc->m_entity.c = ch_entity;
wrapper = (PyObject *)pc;
} else {
PyEntity * pe = newPyEntity();
if (pe == NULL) {
return NULL;
}
pe->m_entity.e = entity;
wrapper = (PyObject *)pe;
}
} else {
PyEntity * pe = newPyLocatedEntity();
if (pe == NULL) {
return NULL;
}
pe->m_entity.l = le;
wrapper = (PyObject *)pe;
}
if (le->script() == &noScript) {
pw = new PythonWrapper(wrapper);
le->setScript(pw);
} else {
log(WARNING, "Entity has script of unknown type");
}
} else {
wrapper = pw->wrapper();
assert(wrapper != NULL);
Py_INCREF(wrapper);
}
return wrapper;
}
示例2: wrapTask
PyObject * wrapTask(Task * task)
{
PyObject * wrapper;
Task * ts = dynamic_cast<Task *>(task);
PythonWrapper * pw;
if (ts == 0 || ((pw = dynamic_cast<PythonWrapper *>(ts->script())) == 0)) {
PyTask * pt = newPyTask();
if (pt != NULL) {
pt->m_task = task;
}
wrapper = (PyObject *)pt;
// This wrapper cannot be stashed back int the task yet so
// we don't have to do this next time.
} else {
wrapper = pw->wrapper();
assert(wrapper != NULL);
Py_INCREF(wrapper);
}
return wrapper;
}