/*========================================================================= function.cpp Author: PKG Created: Project: Spongebob Purpose: Copyright (c) 2000 Climax Development Ltd ===========================================================================*/ /*---------------------------------------------------------------------- Includes -------- */ #include "function.h" #ifndef _LEXER_H #include "lexer.h" #endif #ifndef _PARSER_H #include "parser.h" #endif /* Std Lib ------- */ #include #include /* Data ---- */ /*---------------------------------------------------------------------- Tyepdefs && Defines ------------------- */ /*---------------------------------------------------------------------- Structure defintions -------------------- */ struct FunctionDef { char *m_name; int m_argCount; }; /*---------------------------------------------------------------------- Function Prototypes ------------------- */ /*---------------------------------------------------------------------- Vars ---- */ static FunctionDef s_functionNames[]= { { "setCharacterAnimation", 2 }, // characterId,animationId { "setText", 2 }, // characterId,textId { "giveItem", 1 }, // itemId { "gotItem", 1 }, // itemId { "setResponseOptions", 1 }, // optionsId { "getResponse", 0 }, // { "drawSprite", 4 }, // frame,x,y,ot { "getFrameTime", 0 }, // }; static int s_functionCount=sizeof(s_functionNames)/sizeof(FunctionDef); extern mylexer s_lexer; extern myparser s_parser; /*---------------------------------------------------------------------- Function: Purpose: Params: Returns: ---------------------------------------------------------------------- */ extern int lookupFunctionName(char *_name) { int i; FunctionDef *fp; fp=s_functionNames; for(i=0;im_name,_name)==0) { return i; } fp++; } printf("Unknown function name _%s\n",_name); s_lexer.error(); return -1; } /*---------------------------------------------------------------------- Function: Purpose: Params: Returns: Argument count for the requestion function ---------------------------------------------------------------------- */ extern int getFunctionArgCount(int _functionNumber) { return s_functionNames[_functionNumber].m_argCount; } /*---------------------------------------------------------------------- Function: Purpose: Params: Returns: A treenode that contains all of the functions arguments ---------------------------------------------------------------------- */ extern CTreeNode *getFunctionArgs(int _functionNumber) { int argCount,i; int tokenType; argCount=s_functionNames[_functionNumber].m_argCount; if(argCount) { CTreeNode *base; base=NULL; for(i=0;i