예제 #1
0
    Property*  Property::Create(const char* typeName, const char* instanceName, const char* agentType, const char* propertyName, const char* valueStr)
    {
        BEHAVIAC_ASSERT(propertyName);
        BEHAVIAC_ASSERT(!StringUtils::EndsWith(propertyName, "]"));

        const CMemberBase* pMember = 0;
        bool bConst = false;

        if (agentType)
        {
            CStringID agentClassId(agentType);
            CStringID propertyId(propertyName);

            pMember = Agent::FindMemberBase(agentClassId, propertyId);
        }
        else
        {
            BEHAVIAC_ASSERT(true);
        }

        Property*  p = Property::create(pMember, bConst, typeName, propertyName, instanceName, valueStr);

        return p;
    }
예제 #2
0
    behaviac::CMethodBase* Action::LoadMethod(const char* value_)
    {
        //Self.test_ns::AgentActionTest::Action2(0)
        char agentIntanceName[kNameLength];
        char agentClassName[kNameLength];
        char methodName[kNameLength];

        const char* pBeginP = ParseMethodNames(value_, agentIntanceName, agentClassName, methodName);

        //propertyName = FormatString("%s::%s", agentClassName, methodName);
        CStringID agentClassId(agentClassName);
        CStringID methodId(methodName);

        behaviac::CMethodBase* method = Agent::CreateMethod(agentClassId, methodId);

        if (!method)
        {
            BEHAVIAC_LOGWARNING("No Method %s::%s registered\n", agentClassName, methodName);
            BEHAVIAC_ASSERT(0, "No Method %s::%s registered\n", agentClassName, methodName);
        }
        else
        {
            //if (Agent::IsInstanceNameRegistered(agentIntanceName))
            {
                method->SetInstanceNameString(agentIntanceName, PT_INSTANCE);
            }

            BEHAVIAC_ASSERT(method, "No Method %s::%s registered", agentClassName, methodName);
            const char* params = pBeginP;

            BEHAVIAC_ASSERT(params[0] == '(');

            behaviac::vector<behaviac::string> tokens;

            {
                size_t len = strlen(params);

                BEHAVIAC_ASSERT(params[len - 1] == ')');

                behaviac::string text = behaviac::string(params + 1, len - 2);
                //behaviac::StringUtils::SplitIntoArray(text, ",", tokens);
                ParseForParams(text, tokens);
            }

            if (tokens.size() > 0)
            {
                XmlNodeRef xmlNode = CreateXmlNode("Method");

                for (uint32_t i = 0; i < tokens.size(); ++i)
                {
                    const behaviac::string& token = tokens[i];
					char attriName[1024];
					string_sprintf(attriName, "param%d", i + 1);
                    xmlNode->setAttr(attriName, token);
                }

                CTextNode node(xmlNode);
                method->LoadFromXML(0, node);
            }
        }

        return method;
    }