本文整理汇总了C++中SCRIPT_ERROR_CHECK函数的典型用法代码示例。如果您正苦于以下问题:C++ SCRIPT_ERROR_CHECK函数的具体用法?C++ SCRIPT_ERROR_CHECK怎么用?C++ SCRIPT_ERROR_CHECK使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SCRIPT_ERROR_CHECK函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PyObject_CallFunction
//-------------------------------------------------------------------------------------
void PyGC::set_debug(uint32 flsgs)
{
PyObject* pyRet = PyObject_CallFunction(set_debugMethod_,
const_cast<char*>("i"), flsgs);
SCRIPT_ERROR_CHECK();
if(pyRet)
{
S_RELEASE(pyRet);
}
}
示例2: ERROR_MSG
//-------------------------------------------------------------------------------------
int Script::run_simpleString(std::string command, std::string* retBufferPtr)
{
if(retBufferPtr != NULL)
{
if(!pyStdouterrHook_->install()){
ERROR_MSG("Script::Run_SimpleString::pyStdouterrHook_->install() is failed!\n");
SCRIPT_ERROR_CHECK();
return -1;
}
pyStdouterrHook_->setHookBuffer(retBufferPtr);
PyRun_SimpleString(command.c_str());
SCRIPT_ERROR_CHECK(); // 检查是否有错误产生
pyStdouterrHook_->uninstall();
return 0;
}
PyRun_SimpleString(command.c_str());
SCRIPT_ERROR_CHECK(); // 检查是否有错误产生
return 0;
}
示例3: PyObject_CallMethod
//-------------------------------------------------------------------------------------
int32 Proxy::onLogOnAttempt(const char* addr, uint32 port, const char* password)
{
PyObject* pyResult = PyObject_CallMethod(this,
const_cast<char*>("onLogOnAttempt"), const_cast<char*>("uku"),
PyUnicode_FromString(addr),
PyLong_FromLong(port),
PyUnicode_FromString(password)
);
int32 ret = LOG_ON_REJECT;
if(pyResult != NULL)
{
ret = PyLong_AsLong(pyResult);
SCRIPT_ERROR_CHECK();
Py_DECREF(pyResult);
}
else
SCRIPT_ERROR_CHECK();
return ret;
}
示例4: KBE_ASSERT
//-------------------------------------------------------------------------------------
client::Entity* ClientObjectBase::createEntityCommon(const char* entityType, PyObject* params,
bool isInitializeScript, ENTITY_ID eid, bool initProperty,
EntityMailbox* base, EntityMailbox* cell)
{
KBE_ASSERT(eid > 0);
ScriptDefModule* sm = EntityDef::findScriptModule(entityType);
if(sm == NULL)
{
PyErr_Format(PyExc_TypeError, "ClientObjectBase::createEntityCommon: entity [%s] not found.\n", entityType);
PyErr_PrintEx(0);
return NULL;
}
else if(!sm->hasClient())
{
PyErr_Format(PyExc_TypeError, "ClientObjectBase::createEntityCommon: entity [%s] not found.\n", entityType);
PyErr_PrintEx(0);
return NULL;
}
PyObject* obj = sm->createObject();
client::Entity* entity = new(obj) client::Entity(eid, sm, base, cell);
entity->pClientApp(this);
if(initProperty)
entity->initProperty();
// 将entity加入entities
pEntities_->add(eid, entity);
// 初始化脚本
if(isInitializeScript)
entity->initializeEntity(params);
SCRIPT_ERROR_CHECK();
if(g_debugEntity)
{
INFO_MSG(boost::format("ClientObjectBase::createEntityCommon: new %1% (%2%) refc=%3%.\n") % entityType % eid % obj->ob_refcnt);
}
else
{
INFO_MSG(boost::format("ClientObjectBase::createEntityCommon: new %1% (%2%)\n") % entityType % eid);
}
EventData_CreatedEntity eventdata;
eventdata.pEntity = entity->getAspect();
eventHandler_.fire(&eventdata);
return entity;
}
示例5: handleTimeout
virtual void handleTimeout(TimerHandle handle, void * pUser)
{
int id = ScriptTimersUtil::getIDForHandle(scriptTimers_, handle);
PyObject *pyRet = PyObject_CallFunction(pyCallback_, "i", id);
if (pyRet == NULL)
{
SCRIPT_ERROR_CHECK();
return;
}
return;
}
示例6: PyObject_CallFunction
//-------------------------------------------------------------------------------------
PyObject* Copy::deepcopy(PyObject* pyobj)
{
PyObject* pyRet = PyObject_CallFunction(deepcopyMethod_,
const_cast<char*>("(O)"), pyobj);
if(!pyRet)
{
SCRIPT_ERROR_CHECK();
Py_RETURN_NONE;
}
return pyRet;
}
示例7: PyObject_CallFunction
//-------------------------------------------------------------------------------------
PyObject* PyStruct::unpack(PyObject* fmt, PyObject* args)
{
PyObject* pyRet = PyObject_CallFunction(unpack_,
const_cast<char*>("(OO)"), fmt, args);
if (!pyRet)
{
ERROR_MSG("PyStruct::unpack: is failed.\n");
}
SCRIPT_ERROR_CHECK();
return pyRet;
}
示例8: SCOPED_PROFILE
//-------------------------------------------------------------------------------------
int32 Proxy::onLogOnAttempt(const char* addr, uint32 port, const char* password)
{
SCOPED_PROFILE(SCRIPTCALL_PROFILE);
PyObject* pyResult = PyObject_CallMethod(this,
const_cast<char*>("onLogOnAttempt"), const_cast<char*>("sks"),
addr,
port,
password
);
int32 ret = LOG_ON_REJECT;
if(pyResult != NULL)
{
ret = PyLong_AsLong(pyResult);
SCRIPT_ERROR_CHECK();
Py_DECREF(pyResult);
}
else
SCRIPT_ERROR_CHECK();
return ret;
}
示例9: SCRIPT_ERROR_CHECK
//-------------------------------------------------------------------------------------
void Blob::initialize(PyObject* pyBytesInitData)
{
char *buffer;
Py_ssize_t length;
if(PyBytes_AsStringAndSize(pyBytesInitData, &buffer, &length) < 0)
{
SCRIPT_ERROR_CHECK();
return;
}
if(length > 0)
stream_.append(buffer, length);
}
示例10: registerScript
//-------------------------------------------------------------------------------------
bool ClientApp::installPyModules()
{
registerScript(client::Entity::getScriptType());
onInstallPyModules();
// 注册设置脚本输出类型
APPEND_SCRIPT_MODULE_METHOD(getScript().getModule(), scriptLogType, __py_setScriptLogType, METH_VARARGS, 0)
if(PyModule_AddIntConstant(this->getScript().getModule(), "LOG_TYPE_NORMAL", log4cxx::ScriptLevel::SCRIPT_INT))
{
ERROR_MSG( "ClientApp::installPyModules: Unable to set KBEngine.LOG_TYPE_NORMAL.\n");
}
if(PyModule_AddIntConstant(this->getScript().getModule(), "LOG_TYPE_INFO", log4cxx::ScriptLevel::SCRIPT_INFO))
{
ERROR_MSG( "ClientApp::installPyModules: Unable to set KBEngine.LOG_TYPE_INFO.\n");
}
if(PyModule_AddIntConstant(this->getScript().getModule(), "LOG_TYPE_ERR", log4cxx::ScriptLevel::SCRIPT_ERR))
{
ERROR_MSG( "ClientApp::installPyModules: Unable to set KBEngine.LOG_TYPE_ERR.\n");
}
if(PyModule_AddIntConstant(this->getScript().getModule(), "LOG_TYPE_DBG", log4cxx::ScriptLevel::SCRIPT_DBG))
{
ERROR_MSG( "ClientApp::installPyModules: Unable to set KBEngine.LOG_TYPE_DBG.\n");
}
if(PyModule_AddIntConstant(this->getScript().getModule(), "LOG_TYPE_WAR", log4cxx::ScriptLevel::SCRIPT_WAR))
{
ERROR_MSG( "ClientApp::installPyModules: Unable to set KBEngine.LOG_TYPE_WAR.\n");
}
registerPyObjectToScript("entities", pEntities_);
// 安装入口模块
PyObject *entryScriptFileName = PyUnicode_FromString(g_kbeConfig.entryScriptFile());
if(entryScriptFileName != NULL)
{
entryScript_ = PyImport_Import(entryScriptFileName);
SCRIPT_ERROR_CHECK();
S_RELEASE(entryScriptFileName);
if(entryScript_.get() == NULL)
{
return false;
}
}
return true;
}
示例11: PyObject_CallFunction
//-------------------------------------------------------------------------------------
PyObject* Pickler::unpickle(const std::string& str)
{
PyObject* pyRet = PyObject_CallFunction(unPicklerMethod_,
const_cast<char*>("(y#)"), str.data(), str.length());
if (!pyRet)
{
ERROR_MSG(fmt::format("Pickler::unpickle: failed to unpickle[{}] len={}.\n",
str.c_str(), str.length()));
}
SCRIPT_ERROR_CHECK();
return pyRet;
}
示例12: ERROR_MSG
//-------------------------------------------------------------------------------------
bool PyProfile::start(std::string profile)
{
PyProfile::PROFILES::iterator iter = profiles_.find(profile);
if(iter != profiles_.end())
{
ERROR_MSG(boost::format("PyProfile::start: profile(%1%) already exists!\n") % profile);
return false;
}
PyObject* pyRet = PyObject_CallFunction(profileMethod_,
const_cast<char*>(""));
if(!pyRet)
{
SCRIPT_ERROR_CHECK();
return false;
}
PyObject* pyRet1 = PyObject_CallMethod(pyRet, const_cast<char*>("enable"),
const_cast<char*>(""));
if(!pyRet1)
{
SCRIPT_ERROR_CHECK();
Py_DECREF(pyRet);
return false;
}
Py_DECREF(pyRet1);
profiles_[profile] = pyRet;
char buf[MAX_BUF];
kbe_snprintf(buf, MAX_BUF, "print(\"PyProfile::start: profile=%s.\")", profile.c_str());
pScript_->run_simpleString(buf, NULL);
return true;
}
示例13: SCOPED_PROFILE
//-------------------------------------------------------------------------------------
void Loginapp::onReqCreateAccountResult(Network::Channel* pChannel, MemoryStream& s)
{
SERVER_ERROR_CODE failedcode;
std::string accountName;
std::string password;
std::string retdatas = "";
s >> failedcode >> accountName >> password;
s.readBlob(retdatas);
// 把请求交由脚本处理
SCOPED_PROFILE(SCRIPTCALL_PROFILE);
PyObject* pyResult = PyObject_CallMethod(getEntryScript().get(),
const_cast<char*>("onCreateAccountCallbackFromDB"),
const_cast<char*>("sHy#"),
accountName.c_str(),
failedcode,
retdatas.c_str(), retdatas.length());
if(pyResult != NULL)
{
Py_DECREF(pyResult);
}
else
{
SCRIPT_ERROR_CHECK();
}
DEBUG_MSG(fmt::format("Loginapp::onReqCreateAccountResult: accountName={}, failedcode={}.\n",
accountName.c_str(), failedcode));
PendingLoginMgr::PLInfos* ptinfos = pendingCreateMgr_.remove(accountName);
if(ptinfos == NULL)
return;
Network::Channel* pClientChannel = this->networkInterface().findChannel(ptinfos->addr);
if(pClientChannel == NULL)
return;
pClientChannel->extra("");
Network::Bundle* pBundle = Network::Bundle::createPoolObject();
(*pBundle).newMessage(ClientInterface::onCreateAccountResult);
(*pBundle) << failedcode;
(*pBundle).appendBlob(retdatas);
pClientChannel->send(pBundle);
SAFE_RELEASE(ptinfos);
}
示例14: SCOPED_PROFILE
//-------------------------------------------------------------------------------------
void Entity::onRemoteMethodCall(Mercury::Channel* pChannel, MemoryStream& s)
{
SCOPED_PROFILE(SCRIPTCALL_PROFILE);
if(isDestroyed())
{
ERROR_MSG(boost::format("%1%::onRemoteMethodCall: %2% is destroyed!\n") %
getScriptName() % getID());
s.read_skip(s.opsize());
return;
}
ENTITY_METHOD_UID utype = 0;
s >> utype;
DEBUG_MSG(boost::format("Entity::onRemoteMethodCall: entityID %1%, methodType %2%.\n") %
id_ % utype);
MethodDescription* md = scriptModule_->findCellMethodDescription(utype);
if(md == NULL)
{
ERROR_MSG(boost::format("Entity::onRemoteMethodCall: can't found method. utype=%1%, callerID:%2%.\n") % utype % id_);
return;
}
md->currCallerID(this->getID());
PyObject* pyFunc = PyObject_GetAttrString(this, const_cast<char*>
(md->getName()));
if(md != NULL)
{
PyObject* pyargs = md->createFromStream(&s);
if(pyargs)
{
md->call(pyFunc, pyargs);
Py_XDECREF(pyargs);
}
else
{
SCRIPT_ERROR_CHECK();
}
}
Py_XDECREF(pyFunc);
}
示例15: PyObject_CallMethod
//-------------------------------------------------------------------------------------
void PyProfile::print_stats(const std::string& sort, const std::string& profileName)
{
PyProfile::PROFILES::iterator iter = profiles_.find(profileName.c_str());
if(iter == profiles_.end())
{
return;
}
PyObject* pyRet = PyObject_CallMethod(iter->second.get(), const_cast<char*>("print_stats"),
const_cast<char*>("s"), const_cast<char*>(sort.c_str()));
if(pyRet)
Py_DECREF(pyRet);
else
SCRIPT_ERROR_CHECK();
}