cxAny cxActionRootCreate(cxConstChars xml) { cxEngine engine = cxEngineInstance(); cxActionRoot this = cxHashGet(engine->actions, cxHashStrKey(xml)); if(this != NULL){ return this; } cxXMLScript script = cxEngineGetXMLScript(xml); if(script == NULL || script->bytes == NULL){ CX_ERROR("%s script not register",xml); return NULL; } this = CX_CREATE(cxActionRoot); xmlTextReaderPtr reader = cxXMLReaderForScript(script,cxActionRootReaderError, this); if(reader == NULL){ CX_ERROR("create xml reader failed"); return NULL; } CX_EVENT_FIRE(this, onBegin); cxActionRootLoadCodesWithReader(this, reader); cxHashKey key = cxHashStrKey(xml); cxHashSet(this->codes, key, script->bytes); cxHashSet(engine->actions, key, this); CX_EVENT_FIRE(this, onEnd); return this; }
cxBool cxHashRootLoad(cxAny root,cxConstChars xml) { cxXMLScript script = cxEngineGetXMLScript(xml); if(script == NULL){ CX_ERROR("%s script not register",xml); return false; } if(script->bytes == NULL){ CX_ERROR("xml script not load bytes"); return false; } xmlTextReaderPtr reader = cxXMLReaderForScript(script, cxHashRootReaderError, root); if(reader == NULL){ CX_ERROR("create xml reader failed"); return false; } return cxHashRootLoadWithReader(root, reader); }