本文整理汇总了C++中ScValue::setProp方法的典型用法代码示例。如果您正苦于以下问题:C++ ScValue::setProp方法的具体用法?C++ ScValue::setProp怎么用?C++ ScValue::setProp使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ScValue
的用法示例。
在下文中一共展示了ScValue::setProp方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: script
ScValue *ScScript::getVar(char *name) {
ScValue *ret = nullptr;
// scope locals
if (_scopeStack->_sP >= 0) {
if (_scopeStack->getTop()->propExists(name)) {
ret = _scopeStack->getTop()->getProp(name);
}
}
// script globals
if (ret == nullptr) {
if (_globals->propExists(name)) {
ret = _globals->getProp(name);
}
}
// engine globals
if (ret == nullptr) {
if (_engine->_globals->propExists(name)) {
ret = _engine->_globals->getProp(name);
}
}
if (ret == nullptr) {
//RuntimeError("Variable '%s' is inaccessible in the current block. Consider changing the script.", name);
_gameRef->LOG(0, "Warning: variable '%s' is inaccessible in the current block. Consider changing the script (script:%s, line:%d)", name, _filename, _currentLine);
ScValue *val = new ScValue(_gameRef);
ScValue *scope = _scopeStack->getTop();
if (scope) {
scope->setProp(name, val);
ret = _scopeStack->getTop()->getProp(name);
} else {
_globals->setProp(name, val);
ret = _globals->getProp(name);
}
delete val;
}
return ret;
}
示例2: executeInstruction
bool ScScript::executeInstruction() {
bool ret = STATUS_OK;
uint32 dw;
const char *str = nullptr;
//ScValue* op = new ScValue(_gameRef);
_operand->cleanup();
ScValue *op1;
ScValue *op2;
uint32 inst = getDWORD();
switch (inst) {
case II_DEF_VAR:
_operand->setNULL();
dw = getDWORD();
if (_scopeStack->_sP < 0) {
_globals->setProp(_symbols[dw], _operand);
} else {
_scopeStack->getTop()->setProp(_symbols[dw], _operand);
}
break;
case II_DEF_GLOB_VAR:
case II_DEF_CONST_VAR: {
dw = getDWORD();
/* char *temp = _symbols[dw]; // TODO delete */
// only create global var if it doesn't exist
if (!_engine->_globals->propExists(_symbols[dw])) {
_operand->setNULL();
_engine->_globals->setProp(_symbols[dw], _operand, false, inst == II_DEF_CONST_VAR);
}
break;
}
case II_RET:
if (_scopeStack->_sP >= 0 && _callStack->_sP >= 0) {
_scopeStack->pop();
_iP = (uint32)_callStack->pop()->getInt();
} else {
if (_thread) {
_state = SCRIPT_THREAD_FINISHED;
} else {
if (_numEvents == 0 && _numMethods == 0) {
_state = SCRIPT_FINISHED;
} else {
_state = SCRIPT_PERSISTENT;
}
}
}
break;
case II_RET_EVENT:
_state = SCRIPT_FINISHED;
break;
case II_CALL:
dw = getDWORD();
_operand->setInt(_iP);
_callStack->push(_operand);
_iP = dw;
break;
case II_CALL_BY_EXP: {
// push var
// push string
str = _stack->pop()->getString();
char *methodName = new char[strlen(str) + 1];
strcpy(methodName, str);
ScValue *var = _stack->pop();
if (var->_type == VAL_VARIABLE_REF) {
var = var->_valRef;
}
bool res = STATUS_FAILED;
bool triedNative = false;
// we are already calling this method, try native
if (_thread && _methodThread && strcmp(methodName, _threadEvent) == 0 && var->_type == VAL_NATIVE && _owner == var->getNative()) {
triedNative = true;
res = var->_valNative->scCallMethod(this, _stack, _thisStack, methodName);
}
if (DID_FAIL(res)) {
if (var->isNative() && var->getNative()->canHandleMethod(methodName)) {
if (!_unbreakable) {
_waitScript = var->getNative()->invokeMethodThread(methodName);
if (!_waitScript) {
_stack->correctParams(0);
runtimeError("Error invoking method '%s'.", methodName);
_stack->pushNULL();
//.........这里部分代码省略.........