Esempio n. 1
0
void ProgramParser_ns::parseLValue(ScriptVar &v, const char *str) {

	int index = _program->findLocal(str);
	if (index != -1) {
		v.setLocal(&ctxt.locals[index]);
		return;
	}

	AnimationPtr a;
	if (str[1] == '.') {
		a = _vm->_location.findAnimation(&str[2]);
	} else {
		a = ctxt.a;
	}

	if (str[0] == 'X') {
		v.setField(a.get(), &Animation::getX, &Animation::setX);
	} else
	if (str[0] == 'Y') {
		v.setField(a.get(), &Animation::getY, &Animation::setY);
	} else
	if (str[0] == 'Z') {
		v.setField(a.get(), &Animation::getZ, &Animation::setZ);
	} else
	if (str[0] == 'F') {
		v.setField(a.get(), &Animation::getF, &Animation::setF);
	}

}
Esempio n. 2
0
void ProgramParser_br::parseRValue(ScriptVar &v, const char *str) {

	if (isdigit(static_cast<unsigned char>(str[0])) || str[0] == '-') {
		v.setImmediate(atoi(str));
		return;
	}

	int index = _program->findLocal(str);
	if (index != -1) {
		v.setLocal(&ctxt.locals[index]);
		return;
	}

	AnimationPtr a;
	if (str[1] == '.') {
		a = _vm->_location.findAnimation(&str[2]);
		if (!a) {
			error("unknown animation '%s' in script", &str[2]);
		}
	} else
		a = AnimationPtr(ctxt.a);

	if (str[0] == 'X') {
		v.setField(a.get(), &Animation::getX);
	} else
	if (str[0] == 'Y') {
		v.setField(a.get(), &Animation::getY);
	} else
	if (str[0] == 'Z') {
		v.setField(a.get(), &Animation::getZ);
	} else
	if (str[0] == 'F') {
		v.setField(a.get(), &Animation::getF);
	}	else
	if (str[0] == 'N') {
		v.setImmediate(a->getFrameNum());
	} else
	if (str[0] == 'R') {
		v.setRandom(atoi(&str[1]));
	} else
	if (str[0] == 'L') {
#if 0	// disabled because no references to lip sync has been found in the scripts
		v.setField(&_vm->_lipSyncVal);
#endif
		warning("Lip sync instruction encountered! Please notify the team");
	}

}
Esempio n. 3
0
void ProgramParser_ns::parseRValue(ScriptVar &v, const char *str) {

	if (Common::isDigit(str[0]) || str[0] == '-') {
		v.setImmediate(atoi(str));
		return;
	}

	int index = _program->findLocal(str);
	if (index != -1) {
		v.setLocal(&ctxt.locals[index]);
		return;
	}

	AnimationPtr a;
	if (str[1] == '.') {
		a = _vm->_location.findAnimation(&str[2]);
	} else {
		a = ctxt.a;
	}

	if (str[0] == 'X') {
		v.setField(a.get(), &Animation::getX);
	} else
	if (str[0] == 'Y') {
		v.setField(a.get(), &Animation::getY);
	} else
	if (str[0] == 'Z') {
		v.setField(a.get(), &Animation::getZ);
	} else
	if (str[0] == 'F') {
		v.setField(a.get(), &Animation::getF);
	}

}
//virtual 
void 
LispDmiClient::castTo(ScriptVar& value, const ::acdk::lang::dmi::ClazzInfo* toType)
{
  RLispEnvironment lenv = LispEnvironment::lenv();
  if (typeDistance(value, toType) == 262 && toType->isArray() == true)
  {
    RLispList ll = (RLispList)value.getObjectVar();
    RObject oa;
    if (toType->getElementClazzInfo()->array_creator != 0)
      oa = toType->getElementClazzInfo()->array_creator(ll->length());
    else
      oa = new ObjectArray(ll->length());
    for (int i = 0; ll != Nil; ++i)
    {
      ScriptVar tv;
      convertArg(lenv, tv, ll->car());
      oa->invoke("set", i, tv.getObjectVar());
      ll = ll->cdr();
    }
    value = &oa;
  } else
    Super::castTo(value, toType);
}
void
StdDispatch_Test::nameArgs()
{
  const char* cn = "acdk/tools/aunit/DmiTestClass";
  RObject o = (RObject)StdDispatch::New("acdk/tools/aunit/DmiTestClass");

  
  
  int iarg = 42;
  RString sarg = new String("sarg");
  RStringBuffer sbarg = new StringBuffer("sbarg");

  {
    ScriptVarArray args;
    args.push_back(ScriptVar(iarg));
    args.push_back(ScriptVar(&sarg));
    args.push_back(ScriptVar(&sbarg));
    ScriptVar erg = o->invokeMethod( "namedArgsMethod"
                                    , args
                                    , ::acdk::lang::dmi::AcdkDmiClient::getDmiClient()
                                    , Nil
                                    );
    testAssert(erg.getBoolVar() == true);
  }
  {
    StringArray namedArgs(2);
    namedArgs[0] = new String("sarg");
    namedArgs[1] = new String("sbarg");
    ScriptVarArray args;
    args.push_back(ScriptVar(iarg));
    args.push_back(ScriptVar(&sarg));
    args.push_back(ScriptVar(&sbarg));
    ScriptVar erg = o->invokeMethod( "namedArgsMethod"
                                    , args
                                    , ::acdk::lang::dmi::AcdkDmiClient::getDmiClient()
                                    , &namedArgs
                                    );
    testAssert(erg.getBoolVar() == true);
  }

  // order of call is different
  {
    StringArray namedArgs(2);
    namedArgs[0] = new String("sbarg");
    namedArgs[1] = new String("sarg");
    ScriptVarArray args;
    args.push_back(ScriptVar(iarg));
    args.push_back(ScriptVar(&sbarg));
    args.push_back(ScriptVar(&sarg));
    ScriptVar erg = o->invokeMethod( "namedArgsMethod"
                                    , args
                                    , ::acdk::lang::dmi::AcdkDmiClient::getDmiClient()
                                    , &namedArgs
                                    );
    testAssert(erg.getBoolVar() == true);
  }
}