From: Oliver O. <fr...@us...> - 2007-06-17 13:38:43
|
Update of /cvsroot/simspark/simspark/spark/plugin/rubysceneimporter In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv21072/plugin/rubysceneimporter Modified Files: rubysceneimporter.cpp rubysceneimporter.h Log Message: merge from projectx branch Index: rubysceneimporter.h =================================================================== RCS file: /cvsroot/simspark/simspark/spark/plugin/rubysceneimporter/rubysceneimporter.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** rubysceneimporter.h 17 May 2007 17:49:23 -0000 1.4 --- rubysceneimporter.h 17 Jun 2007 13:38:38 -0000 1.5 *************** *** 57,60 **** --- 57,63 ---- typedef std::list<ParamEnv> TParameterStack; + //! mapping from abbreviations to key words + typedef std::map<std::string, std::string> TTranslationTable; + public: RubySceneImporter(); *************** *** 106,109 **** --- 109,117 ---- ParamEnv& GetParamEnv(); + void InitTranslationTable(); + + std::string Lookup(const std::string& key); + + protected: /** true if a scene is automatically unlinked before a new scene *************** *** 128,131 **** --- 136,142 ---- /** a stack of parameter environments */ TParameterStack mParameterStack; + + /** the abbreviaton table */ + TTranslationTable mTranslationTable; }; Index: rubysceneimporter.cpp =================================================================== RCS file: /cvsroot/simspark/simspark/spark/plugin/rubysceneimporter/rubysceneimporter.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** rubysceneimporter.cpp 17 May 2007 17:49:23 -0000 1.4 --- rubysceneimporter.cpp 17 Jun 2007 13:38:38 -0000 1.5 *************** *** 76,79 **** --- 76,81 ---- mAutoUnlink = false; mUpdateSceneDict = false; + + InitTranslationTable(); } *************** *** 87,91 **** } ! void RubySceneImporter::EnableSceneDictionary(bool enable) { mUpdateSceneDict = enable; --- 89,126 ---- } ! void ! RubySceneImporter::InitTranslationTable() ! { ! mTranslationTable.clear(); ! ! // ! mTranslationTable["nd"] = S_NODE; ! mTranslationTable["sel"] = S_SELECT; ! mTranslationTable["pwd"] = S_PWD; ! mTranslationTable["templ"] = S_TEMPLATE; ! mTranslationTable["def"] = S_DEFINE; ! mTranslationTable["att"] = S_ATTACH; ! mTranslationTable["RDS"] = S_DELTASCENE; ! mTranslationTable["RSG"] = S_SCENEGRAPH; ! mTranslationTable["SLT"] = "setLocalTransform"; ! } ! ! ! string RubySceneImporter::Lookup(const std::string& key) ! { ! return ((mTranslationTable.find(key) != mTranslationTable.end()) ? ! mTranslationTable[key] : key); ! // if (mTranslationTable.find(key) != mTranslationTable.end()) ! // { ! // return mTranslationTable[key]; ! // } else { ! // GetLog()->Debug() << "DEBUG: " << key << " not in TranslationTable\n"; ! // return key; ! // } ! } ! ! ! void ! RubySceneImporter::EnableSceneDictionary(bool enable) { mUpdateSceneDict = enable; *************** *** 235,241 **** return false; } ! ! string val(sexp->val); ! mDeltaScene = false; if (val == S_DELTASCENE) --- 270,276 ---- return false; } ! ! string val = Lookup(string(sexp->val)); ! mDeltaScene = false; if (val == S_DELTASCENE) *************** *** 319,323 **** } ! string className(sexp->val); // create a class instance --- 354,358 ---- } ! string className(Lookup(sexp->val)); // create a class instance *************** *** 421,425 **** } ! string pred = sexp->val; if (pred != "eval") { --- 456,460 ---- } ! string pred = Lookup(sexp->val); if (pred != "eval") { *************** *** 439,443 **** if (sexp->ty == SEXP_VALUE) { ! atom = sexp->val; if ( (atom[0] == '$') && --- 474,478 ---- if (sexp->ty == SEXP_VALUE) { ! atom = sexp->val; //todo: use TranslationTable here? if ( (atom[0] == '$') && *************** *** 580,584 **** // read the method name ! string method = sexp->val; sexp = sexp->next; --- 615,619 ---- // read the method name ! string method = Lookup(sexp->val); sexp = sexp->next; *************** *** 601,605 **** } else { ! param = sexp->val; if ( --- 636,640 ---- } else { ! param = sexp->val; //Todo: use TranslationTable here? if ( *************** *** 622,626 **** bool RubySceneImporter::ParseDefine(sexp_t* sexp) { ! string varname = sexp->val; sexp = sexp->next; --- 657,661 ---- bool RubySceneImporter::ParseDefine(sexp_t* sexp) { ! string varname = sexp->val; //Todo: use TranslationTable here? sexp = sexp->next; *************** *** 705,709 **** ) { ! string param = sexp->val; if (param.size() == 0) --- 740,744 ---- ) { ! string param = sexp->val; //todo: use abbrevTable here? if (param.size() == 0) *************** *** 754,759 **** case SEXP_VALUE: { - string name(sexp->val); if (name == S_NODE) { --- 789,795 ---- case SEXP_VALUE: { + string name = Lookup(string(sexp->val)); + if (name == S_NODE) { *************** *** 780,784 **** if ( (sub->ty == SEXP_VALUE) && ! (string(sub->val) == S_NODE) ) { --- 816,820 ---- if ( (sub->ty == SEXP_VALUE) && ! (Lookup(string(sub->val)) == S_NODE) ) { *************** *** 817,822 **** case SEXP_VALUE: { ! string name(sexp->val); ! if (name == S_NODE) { --- 853,859 ---- case SEXP_VALUE: { ! ! string name = Lookup(string(sexp->val)); ! if (name == S_NODE) { *************** *** 835,839 **** { sexp = sexp->next; ! string name(sexp->val); shared_ptr<BaseNode> node = --- 872,876 ---- { sexp = sexp->next; ! string name(sexp->val); //todo: use abbrevTable here? shared_ptr<BaseNode> node = |