当前位置: 首页>>代码示例>>C++>>正文


C++ PropertyDescription::newDefaultVal方法代码示例

本文整理汇总了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()));
		}
	}
}
开发者ID:Weooh,项目名称:kbengine,代码行数:58,代码来源:entity_component.cpp

示例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();
}
开发者ID:Eayon,项目名称:kbengine,代码行数:58,代码来源:base.cpp

示例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);
}
开发者ID:,项目名称:,代码行数:40,代码来源:


注:本文中的PropertyDescription::newDefaultVal方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。