本文整理汇总了C++中PropertyDescription::newDefaultVal方法的典型用法代码示例。如果您正苦于以下问题:C++ PropertyDescription::newDefaultVal方法的具体用法?C++ PropertyDescription::newDefaultVal怎么用?C++ PropertyDescription::newDefaultVal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PropertyDescription
的用法示例。
在下文中一共展示了PropertyDescription::newDefaultVal方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initProperty
//-------------------------------------------------------------------------------------
void EntityComponent::initProperty(bool isReload)
{
ScriptDefModule::PROPERTYDESCRIPTION_MAP* oldpropers = NULL;
if (isReload)
{
ScriptDefModule* pOldScriptDefModule =
EntityDef::findOldScriptModule(pComponentDescrs_->getName());
if (!pOldScriptDefModule)
{
ERROR_MSG(fmt::format("{}::initProperty: not found old_module!\n",
pComponentDescrs_->getName()));
KBE_ASSERT(false && "EntityComponent::initProperty: not found old_module");
}
oldpropers = &pOldScriptDefModule->getPropertyDescrs();
}
const ScriptDefModule::PROPERTYDESCRIPTION_MAP* pPropertyDescrs = pChildPropertyDescrs();
ScriptDefModule::PROPERTYDESCRIPTION_MAP::const_iterator iter = pPropertyDescrs->begin();
for (; iter != pPropertyDescrs->end(); ++iter)
{
PropertyDescription* propertyDescription = iter->second;
DataType* dataType = propertyDescription->getDataType();
if (oldpropers)
{
ScriptDefModule::PROPERTYDESCRIPTION_MAP::iterator olditer = oldpropers->find(iter->first);
if (olditer != oldpropers->end())
{
if (strcmp(olditer->second->getDataType()->getName(),
propertyDescription->getDataType()->getName()) == 0 &&
strcmp(olditer->second->getDataType()->getName(),
propertyDescription->getDataType()->getName()) == 0)
continue;
}
}
if (dataType)
{
PyObject* defObj = propertyDescription->newDefaultVal();
PyObject_SetAttrString(static_cast<PyObject*>(this),
propertyDescription->getName(), defObj);
Py_DECREF(defObj);
/* DEBUG_MSG(fmt::format("EntityComponent::"#CLASS": added [{}] property ref={}.\n",
propertyDescription->getName(), defObj->ob_refcnt));*/
}
else
{
ERROR_MSG(fmt::format("EntityComponent::initProperty: {} dataType is NULL.\n",
propertyDescription->getName()));
}
}
}
示例2: createCellData
//-------------------------------------------------------------------------------------
void Base::createCellData(void)
{
if(!scriptModule_->hasCell() || !installCellDataAttr())
{
if(scriptModule_->getCellPropertyDescriptions().size() > 0)
{
if(!scriptModule_->hasCell())
{
WARNING_MSG(fmt::format("{}::createCellData: do not create cellData, cannot find the cellapp script({})!\n",
scriptModule_->getName(), scriptModule_->getName()));
}
}
return;
}
ScriptDefModule::PROPERTYDESCRIPTION_MAP& propertyDescrs = scriptModule_->getCellPropertyDescriptions();
ScriptDefModule::PROPERTYDESCRIPTION_MAP::const_iterator iter = propertyDescrs.begin();
for(; iter != propertyDescrs.end(); ++iter)
{
PropertyDescription* propertyDescription = iter->second;
DataType* dataType = propertyDescription->getDataType();
if(dataType)
{
PyObject* pyObj = propertyDescription->newDefaultVal();
PyDict_SetItemString(cellDataDict_, propertyDescription->getName(), pyObj);
Py_DECREF(pyObj);
}
else
{
ERROR_MSG(fmt::format("{}::createCellData: {} PropertyDescription the dataType is NULL.\n",
this->scriptName(), propertyDescription->getName()));
}
SCRIPT_ERROR_CHECK();
}
// 初始化cellEntity的位置和方向变量
PyObject* position = PyTuple_New(3);
PyTuple_SET_ITEM(position, 0, PyFloat_FromDouble(0.0));
PyTuple_SET_ITEM(position, 1, PyFloat_FromDouble(0.0));
PyTuple_SET_ITEM(position, 2, PyFloat_FromDouble(0.0));
PyObject* direction = PyTuple_New(3);
PyTuple_SET_ITEM(direction, 0, PyFloat_FromDouble(0.0));
PyTuple_SET_ITEM(direction, 1, PyFloat_FromDouble(0.0));
PyTuple_SET_ITEM(direction, 2, PyFloat_FromDouble(0.0));
PyDict_SetItemString(cellDataDict_, "position", position);
PyDict_SetItemString(cellDataDict_, "direction", direction);
Py_DECREF(position);
Py_DECREF(direction);
SCRIPT_ERROR_CHECK();
}
示例3: createCellData
//-------------------------------------------------------------------------------------
void Base::createCellData(void)
{
if(!installCellDataAttr())
return;
ScriptDefModule::PROPERTYDESCRIPTION_MAP& propertyDescrs = scriptModule_->getCellPropertyDescriptions();
ScriptDefModule::PROPERTYDESCRIPTION_MAP::const_iterator iter = propertyDescrs.begin();
for(; iter != propertyDescrs.end(); iter++)
{
PropertyDescription* propertyDescription = iter->second;
DataType* dataType = propertyDescription->getDataType();
if(dataType)
{
PyObject* pyObj = propertyDescription->newDefaultVal();
PyDict_SetItemString(cellDataDict_, propertyDescription->getName(), pyObj);
}
else
{
ERROR_MSG("Base::createCellData: %s PropertyDescription the dataType is NULL.\n",
propertyDescription->getName());
}
}
// 初始化cellEntity的位置和方向变量
PyObject* position = PyTuple_New(3);
PyTuple_SET_ITEM(position, 0, PyFloat_FromDouble(0.0));
PyTuple_SET_ITEM(position, 1, PyFloat_FromDouble(0.0));
PyTuple_SET_ITEM(position, 2, PyFloat_FromDouble(0.0));
PyObject* direction = PyTuple_New(3);
PyTuple_SET_ITEM(direction, 0, PyFloat_FromDouble(0.0));
PyTuple_SET_ITEM(direction, 1, PyFloat_FromDouble(0.0));
PyTuple_SET_ITEM(direction, 2, PyFloat_FromDouble(0.0));
PyDict_SetItemString(cellDataDict_, "position", position);
PyDict_SetItemString(cellDataDict_, "direction", direction);
}