OSDN Git Service

fixed the global variable was not a allocator is set
authornothan <nothan87@gmail.com>
Thu, 17 Feb 2011 19:28:07 +0000 (04:28 +0900)
committernothan <nothan87@gmail.com>
Thu, 17 Feb 2011 19:28:07 +0000 (04:28 +0900)
added The active tag can specify a variable
fixed callAction/callEvent get an error when specifying the object

src/livemlparser.cpp
src/livemlparser.h
src/livemlrunner.cpp
test/test.xml

index 93c3981..e3f51c6 100644 (file)
@@ -250,6 +250,8 @@ PARAM_VAR(registerParameterType(paramVar))
   reg = addTagType("active");
   po = reg->addParameter();
   po->set(0, PARAM_TEXT);
+  po = reg->addParameter();
+  po->set(1, PARAM_VAR, "val");
 
   // event
   reg = addTagType("event");
@@ -268,14 +270,14 @@ PARAM_VAR(registerParameterType(paramVar))
   po = reg->addParameter();
   po->set(0, PARAM_TEXT);
   po = reg->addParameter();
-  po->set(1, PARAM_TEXT, "target");
+  po->set(1, PARAM_NUMERIC, "target");
 
   // callEvent
   reg = addTagType("callEvent");
   po = reg->addParameter();
   po->set(0, PARAM_TEXT);
   po = reg->addParameter();
-  po->set(1, PARAM_TEXT, "target");
+  po->set(1, PARAM_NUMERIC, "target");
 
   // include
   reg = addTagType("include");
index 3b14bc4..11484c0 100644 (file)
@@ -57,9 +57,9 @@ enum
   VAR_SCOPE_GLOBAL,
   VAR_SCOPE_MAX
 };
-#define VAR_GLOBAL_ID(scope, id) ((0x10000000 << scope) | id)
-#define VAR_LOCAL_ID(id) (0x0FFFFFFF & id)
-#define VAR_SCOPE_TYPE(id) ((0xF0000000 & id) >> 29)
+#define VAR_GLOBAL_ID(scope, id) ((0x00100000 << scope) | id)
+#define VAR_LOCAL_ID(id) (0x000FFFFF & id)
+#define VAR_SCOPE_TYPE(id) ((0x00F00000 & id) >> 21)
 
 template <class T>
 class TagContainer : public NameContainer<T>
index 6708b1c..68ba1b1 100644 (file)
@@ -162,7 +162,14 @@ namespace lmlCommand
 #ifdef DEBUG
     printf("active [%s]\n", param.getText(0));
 #endif
-    param.runner->addActor(param.getText(0));
+    LMLActorObject *obj = param.runner->addActor(param.getText(0));
+    if (param.has(1))
+    {
+      variable_size id = *(variable_size*)param.get(1);
+      size_t objId = param.runner->getActorObjectId(*obj);
+
+      param.getVariable(id)->setFixedFloat(id, int_to_fixed_float((int)objId));
+    }
 
     return LML_CMDRTN_NEXT;
   }
@@ -243,6 +250,14 @@ namespace lmlCommand
       obj->setAction(ap);
     }
 
+    if(obj != param.obj && obj->activeActionStack.has())
+    {
+      LMLParameter p(NULL, param.runner, obj, &obj->activeActionStack);
+      LML_CMDRTN result = param.runner->runAction(p);
+
+      return LML_CMDRTN_NEXT;
+    }
+
     return LML_CMDRTN_STOP | LML_CMDRTN_NEXT | LML_CMDRTN_REACTION;
   }
 
@@ -261,7 +276,7 @@ namespace lmlCommand
       obj = param.obj;
     }
 
-    if (&param.obj->activeActionStack == param.actionStack)
+    if (param.obj != obj || &param.obj->activeActionStack == param.actionStack)
     {
       param.runner->callEvent(*obj, param.getText(0));
       return LML_CMDRTN_NEXT;
@@ -284,6 +299,7 @@ LiveMLRunner::LiveMLRunner(LiveMLParser *p)
   _commandFuncs.resize(parser->countTagType());
   _currentActor = NULL;
   _currentObject = NULL;
+  variable.numericList.allocator(&_numericVariableAllocator);
 
   _scene.setVariableAllocator(&_numericVariableAllocator);
   _scene.setRepeatAllocator(&_repeatAllocator);
@@ -338,11 +354,14 @@ LML_CMDRTN LiveMLRunner::runCommand(LMLParameter &param, Tag *tag)
     rt = tag->param.getTag(0)->type;
     func = _commandFuncs[rt->id].closeFunc;
 #ifdef DEBUG
-    printf("close tag: %s\n", rt->getName().c_str());
+    printf("close tag: %s[%d]\n", rt->getName().c_str(), rt->id);
 #endif
   }
   else
   {
+#ifdef DEBUG
+    printf("tag: %s[%d]\n", rt->getName().c_str(), rt->id);
+#endif
     func = _commandFuncs[rt->id].func;
   }
 
index 24d20db..3f50c57 100644 (file)
@@ -7,11 +7,12 @@
     </event>
     <!-- Local Actions -->
     <action name="1">
-      <active>actor</active>
+      <active val="g.ACTOR">actor</active>
+      <callAction target="$g.ACTOR">action2</callAction>
       <callAction>g1</callAction>
     </action>
     <action name="2">
-      <print>call[action 2]</print>
+      <print>call[scene1.action2]</print>
       <callAction>g2</callAction>
     </action>
   </scene>
     <action name="action">
       <val name="a">10</val>
       <repeat count="$a">
-        <print>roop[actor]</print>
+        <print>roop[actor.action]</print>
         <wait>1</wait>
       </repeat>
       <callEvent>release</callEvent>
     </action>
+    <action name="action2">
+      <print>call[actor.action2]</print>
+    </action>
   </actor>
 
   <!--Global Actions -->
   <action name="g1">
-    <print>call[global action 1]</print>
+    <print>call[global action1]</print>
     <callAction>2</callAction>
   </action>
   <action name="g2">
-    <print>call[global action 2]</print>
+    <print>call[global action2]</print>
   </action>
 </liveml>