本文整理汇总了C++中ScValue::copy方法的典型用法代码示例。如果您正苦于以下问题:C++ ScValue::copy方法的具体用法?C++ ScValue::copy怎么用?C++ ScValue::copy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ScValue
的用法示例。
在下文中一共展示了ScValue::copy方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: push
void ScStack::push(ScValue *val) {
_sP++;
if (_sP < (int32)_values.size()) {
_values[_sP]->cleanup();
_values[_sP]->copy(val);
} else {
ScValue *copyVal = new ScValue(_gameRef);
copyVal->copy(val);
_values.add(copyVal);
}
}
示例2: setProp
bool ScValue::setProp(const char *name, ScValue *val, bool copyWhole, bool setAsConst) {
if (_type == VAL_VARIABLE_REF) {
return _valRef->setProp(name, val);
}
bool ret = STATUS_FAILED;
if (_type == VAL_NATIVE && _valNative) {
ret = _valNative->scSetProperty(name, val);
}
if (DID_FAIL(ret)) {
ScValue *newVal = nullptr;
_valIter = _valObject.find(name);
if (_valIter != _valObject.end()) {
newVal = _valIter->_value;
}
if (!newVal) {
newVal = new ScValue(_gameRef);
} else {
newVal->cleanup();
}
newVal->copy(val, copyWhole);
newVal->_isConstVar = setAsConst;
_valObject[name] = newVal;
if (_type != VAL_NATIVE) {
_type = VAL_OBJECT;
}
/*
_valIter = _valObject.find(Name);
if (_valIter != _valObject.end()) {
delete _valIter->_value;
_valIter->_value = nullptr;
}
ScValue* val = new ScValue(_gameRef);
val->Copy(Val, CopyWhole);
val->_isConstVar = SetAsConst;
_valObject[Name] = val;
if (_type!=VAL_NATIVE) _type = VAL_OBJECT;
*/
}
return STATUS_OK;
}
示例3: executeInstruction
//.........这里部分代码省略.........
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();
} else {
_state = SCRIPT_WAITING_SCRIPT;
_waitScript->copyParameters(_stack);
}
} else {
// can call methods in unbreakable mode
_stack->correctParams(0);
runtimeError("Cannot call method '%s'. Ignored.", methodName);
_stack->pushNULL();
}
delete[] methodName;
break;
}
/*
ScValue* val = var->getProp(MethodName);
if (val) {
dw = GetFuncPos(val->getString());
if (dw==0) {
TExternalFunction* f = GetExternal(val->getString());
if (f) {
ExternalCall(_stack, _thisStack, f);
}
else{
// not an internal nor external, try for native function
_gameRef->ExternalCall(this, _stack, _thisStack, val->getString());
}
}
else{
_operand->setInt(_iP);
_callStack->Push(_operand);
_iP = dw;
}
}
*/
else {