2 * Acess2 - SpiderScript
8 #include <spiderscript.h>
12 extern tAST_Script *Parse_Buffer(tSpiderVariant *Variant, char *Buffer);
16 * \brief Library Entry Point
24 * \brief Parse a script
26 tSpiderScript *SpiderScript_ParseFile(tSpiderVariant *Variant, const char *Filename)
33 fp = fopen(Filename, "r");
38 ret = malloc(sizeof(tSpiderScript));
39 ret->Variant = Variant;
41 fseek(fp, 0, SEEK_END);
43 fseek(fp, 0, SEEK_SET);
46 if(!data) return NULL;
47 fread(data, fLen, 1, fp);
51 ret->Script = Parse_Buffer(Variant, data);
59 * \brief Execute a script function
62 tSpiderVariable *SpiderScript_ExecuteMethod(tSpiderScript *Script, const char *Function)
64 tAST_Function *fcn = Script->Script->Functions;
67 for( ; fcn; fcn = fcn->Next ) {
68 if( strcmp(fcn->Name, Function) == 0 )
74 return AST_ExecuteNode(Script, fcn->Code);
78 * \brief Free a script
80 void SpiderScript_Free(tSpiderScript *Script)
82 tAST_Function *fcn = Script->Script->Functions;
83 tAST_Function *nextFcn;
84 tAST_Node *var, *nextVar;
88 AST_FreeNode( fcn->Code );
93 nextVar = var->NextSibling;