2 Jan 2004 17:01
cel/plugins/behaviourlayer/xml blxml.cpp,1.39,1.40 xmlscript.cpp,1.48,1.49
Update of /cvsroot/cel/cel/plugins/behaviourlayer/xml
In directory sc8-pr-cvs1:/tmp/cvs-serv29764/plugins/behaviourlayer/xml
Modified Files:
blxml.cpp xmlscript.cpp
Log Message:
- Jorrit added the ability to use parameters for the
'call' operation in the XML behaviour layer.
Index: blxml.cpp
===================================================================
RCS file: /cvsroot/cel/cel/plugins/behaviourlayer/xml/blxml.cpp,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -d -r1.39 -r1.40
--- blxml.cpp 30 Dec 2003 14:32:27 -0000 1.39
+++ blxml.cpp 2 Jan 2004 16:01:43 -0000 1.40
<at> <at> -920,6 +920,33 <at> <at>
break;
case XMLTOKEN_CALL:
{
+ csRef<iDocumentNodeIterator> child_it = child->GetNodes ();
+ uint32 cnt = 0;
+ while (child_it->HasNext ())
+ {
+ csRef<iDocumentNode> c = child_it->Next ();
+ if (c->GetType () != CS_NODE_ELEMENT) continue;
+ if (xmltokens.Request (c->GetValue ()) == XMLTOKEN_PAR) cnt++;
+ else synldr->ReportBadToken (c);
+ }
+ h->AddOperation (CEL_OPERATION_ACTIONPARAMS);
+ h->GetArgument ().SetUInt32 (cnt);
+
+ child_it = child->GetNodes ();
+ cnt = 0;
+ while (child_it->HasNext ())
+ {
+ csRef<iDocumentNode> c = child_it->Next ();
+ if (c->GetType () != CS_NODE_ELEMENT) continue;
+ if (!ParseExpression (c, h, "id", "call/par"))
+ return false;
+ if (!ParseExpression (c, h, "value", "call/par"))
+ return false;
+ h->AddOperation (CEL_OPERATION_ACTIONPARAM);
+ h->GetArgument ().SetUInt32 (cnt);
+ cnt++;
+ }
+
const char* entname = child->GetAttributeValue ("entity");
if (entname)
if (!ParseExpression (child, h, "entity", "call"))
<at> <at> -930,6 +957,43 <at> <at>
CEL_OPERATION_CALL);
}
break;
+ case XMLTOKEN_ACTION:
+ {
+ csRef<iDocumentNodeIterator> child_it = child->GetNodes ();
+ uint32 cnt = 0;
+ while (child_it->HasNext ())
+ {
+ csRef<iDocumentNode> c = child_it->Next ();
+ if (c->GetType () != CS_NODE_ELEMENT) continue;
+ if (xmltokens.Request (c->GetValue ()) == XMLTOKEN_PAR) cnt++;
+ else synldr->ReportBadToken (c);
+ }
+ h->AddOperation (CEL_OPERATION_ACTIONPARAMS);
+ h->GetArgument ().SetUInt32 (cnt);
+
+ child_it = child->GetNodes ();
+ cnt = 0;
+ while (child_it->HasNext ())
+ {
+ csRef<iDocumentNode> c = child_it->Next ();
+ if (c->GetType () != CS_NODE_ELEMENT) continue;
+ if (!ParseExpression (c, h, "id", "action/par"))
+ return false;
+ if (!ParseExpression (c, h, "value", "action/par"))
+ return false;
+ h->AddOperation (CEL_OPERATION_ACTIONPARAM);
+ h->GetArgument ().SetUInt32 (cnt);
+ cnt++;
+ }
+
+ if (!ParseExpression (child, h, "propclass", "action",
+ CEL_DATA_PCLASS))
+ return false;
+ if (!ParseExpression (child, h, "id", "action"))
+ return false;
+ h->AddOperation (CEL_OPERATION_ACTION);
+ }
+ break;
case XMLTOKEN_DESTROYENTITY:
if (!ParseExpression (child, h, "name", "destroyentity")) return false;
h->AddOperation (CEL_OPERATION_DESTROYENTITY);
<at> <at> -1152,43 +1216,6 <at> <at>
if (!ParseExpression (child, h, "value", "property"))
return false;
h->AddOperation (CEL_OPERATION_PROPERTY);
- }
- break;
- case XMLTOKEN_ACTION:
- {
- csRef<iDocumentNodeIterator> child_it = child->GetNodes ();
- uint32 cnt = 0;
- while (child_it->HasNext ())
- {
- csRef<iDocumentNode> c = child_it->Next ();
- if (c->GetType () != CS_NODE_ELEMENT) continue;
- if (xmltokens.Request (c->GetValue ()) == XMLTOKEN_PAR) cnt++;
- else synldr->ReportBadToken (c);
- }
- h->AddOperation (CEL_OPERATION_ACTIONPARAMS);
- h->GetArgument ().SetUInt32 (cnt);
-
- child_it = child->GetNodes ();
- cnt = 0;
- while (child_it->HasNext ())
- {
- csRef<iDocumentNode> c = child_it->Next ();
- if (c->GetType () != CS_NODE_ELEMENT) continue;
- if (!ParseExpression (c, h, "id", "action/par"))
- return false;
- if (!ParseExpression (c, h, "value", "action/par"))
- return false;
- h->AddOperation (CEL_OPERATION_ACTIONPARAM);
- h->GetArgument ().SetUInt32 (cnt);
- cnt++;
- }
-
- if (!ParseExpression (child, h, "propclass", "action",
- CEL_DATA_PCLASS))
- return false;
- if (!ParseExpression (child, h, "id", "action"))
- return false;
- h->AddOperation (CEL_OPERATION_ACTION);
}
break;
default:
Index: xmlscript.cpp
===================================================================
RCS file: /cvsroot/cel/cel/plugins/behaviourlayer/xml/xmlscript.cpp,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -d -r1.48 -r1.49
--- xmlscript.cpp 30 Dec 2003 14:32:27 -0000 1.48
+++ xmlscript.cpp 2 Jan 2004 16:01:43 -0000 1.49
<at> <at> -666,6 +666,9 <at> <at>
case CEL_DATA_ULONG:
stack[si].SetUInt32 (data->value.ul);
break;
+ case CEL_DATA_PCLASS:
+ stack[si].SetPC (data->value.pc);
+ break;
case CEL_DATA_ENTITY:
stack[si].SetEntity (data->value.ent);
break;
<at> <at> -2044,6 +2047,14 <at> <at>
ent->SetBehaviour (bh);
}
break;
+ case CEL_OPERATION_CALLI:
+ {
+ celXmlScriptEventHandler* handler = op.arg.arg.h.h_true;
+ CS_ASSERT (handler != 0);
+ DUMP_EXEC ((":%04d: calli %s\n", i-1, handler->GetName ()));
+ handler->Execute (entity, behave, params);
+ }
+ break;
case CEL_OPERATION_CALLENT:
{
CHECK_STACK
<at> <at> -2057,15 +2068,9 <at> <at>
return ReportError (behave, "Couldn't find entity '%s'!",
EntityNameForError (aent));
const char* eventname = ArgToString (aevent);
- ent->GetBehaviour ()->SendMessage (eventname, 0);
- }
- break;
- case CEL_OPERATION_CALLI:
- {
- celXmlScriptEventHandler* handler = op.arg.arg.h.h_true;
- CS_ASSERT (handler != 0);
- DUMP_EXEC ((":%04d: calli %s\n", i-1, handler->GetName ()));
- handler->Execute (entity, behave, params);
+ action_params->IncRef ();
+ ent->GetBehaviour ()->SendMessage (eventname, action_params);
+ action_params->DecRef ();
}
break;
case CEL_OPERATION_CALL:
<at> <at> -2074,7 +2079,25 <at> <at>
celXmlArg aevent = stack.Pop ();
DUMP_EXEC ((":%04d: call event=%s\n", i-1, A2S (aevent)));
const char* eventname = ArgToString (aevent);
- behave->SendMessage (eventname, 0);
+ action_params->IncRef ();
+ behave->SendMessage (eventname, action_params);
+ action_params->DecRef ();
+ }
+ break;
+ case CEL_OPERATION_ACTION:
+ {
+ CHECK_STACK
+ celXmlArg a_id = stack.Pop ();
+ CHECK_STACK
+ celXmlArg a_pc = stack.Pop ();
+ DUMP_EXEC ((":%04d: action pc=%s id=%d\n", i-1, A2S (a_pc),
+ A2S (a_id)));
+ iCelPropertyClass* pc = ArgToPClass (a_pc);
+ if (!pc) pc = default_pc;
+ csStringID id = ArgToID (a_id);
+ action_params->IncRef ();
+ pc->PerformAction (id, action_params);
+ action_params->DecRef ();
}
break;
case CEL_OPERATION_DESTROYENTITY:
<at> <at> -2303,6 +2326,8 <at> <at>
celData& data = action_params->GetParameter ((int)op.arg.arg.ui);
switch (a_val.type)
{
+ case CEL_DATA_ENTITY: data.Set (a_val.arg.entity); break;
+ case CEL_DATA_PCLASS: data.Set (a_val.arg.pc); break;
case CEL_DATA_LONG: data.Set (a_val.arg.i); break;
case CEL_DATA_ULONG: data.Set (a_val.arg.ui); break;
case CEL_DATA_BOOL: data.SetBool (a_val.arg.b); break;
<at> <at> -2338,20 +2363,6 <at> <at>
return ReportError (behave, "Bad type of value!");
}
}
- break;
- case CEL_OPERATION_ACTION:
- {
- CHECK_STACK
- celXmlArg a_id = stack.Pop ();
- CHECK_STACK
- celXmlArg a_pc = stack.Pop ();
- DUMP_EXEC ((":%04d: action pc=%s id=%d\n", i-1, A2S (a_pc),
- A2S (a_id)));
- iCelPropertyClass* pc = ArgToPClass (a_pc);
- if (!pc) pc = default_pc;
- csStringID id = ArgToID (a_id);
- pc->PerformAction (id, action_params);
- }
break;
case CEL_OPERATION_VARENT:
{
RSS Feed