orx  1.14
Portable Game Engine
orxCommand.h
Go to the documentation of this file.
1 /* Orx - Portable Game Engine
2  *
3  * Copyright (c) 2008-2022 Orx-Project
4  *
5  * This software is provided 'as-is', without any express or implied
6  * warranty. In no event will the authors be held liable for any damages
7  * arising from the use of this software.
8  *
9  * Permission is granted to anyone to use this software for any purpose,
10  * including commercial applications, and to alter it and redistribute it
11  * freely, subject to the following restrictions:
12  *
13  * 1. The origin of this software must not be misrepresented; you must not
14  * claim that you wrote the original software. If you use this software
15  * in a product, an acknowledgment in the product documentation would be
16  * appreciated but is not required.
17  *
18  * 2. Altered source versions must be plainly marked as such, and must not be
19  * misrepresented as being the original software.
20  *
21  * 3. This notice may not be removed or altered from any source
22  * distribution.
23  */
24 
40 #ifndef _orxCOMMAND_H_
41 #define _orxCOMMAND_H_
42 
43 
44 #include "orxInclude.h"
45 #include "math/orxVector.h"
46 
47 
50 #define orxCOMMAND_KC_BLOCK_MARKER '"'
51 #define orxCOMMAND_KC_PUSH_MARKER '>'
52 #define orxCOMMAND_KC_POP_MARKER '<'
53 #define orxCOMMAND_KC_GUID_MARKER '^'
54 #define orxCOMMAND_KC_SEPARATOR ','
59 typedef enum __orxCOMMAND_VAR_TYPE_t
60 {
70 
72 
73  orxCOMMAND_VAR_TYPE_NONE = orxENUM_NONE
74 
76 
77 
80 typedef struct __orxCOMMAND_VAR_DEF_t
81 {
82  const orxSTRING zName;
86 
88 typedef struct __orxCOMMAND_VAR_t
89 {
90  union
91  {
93  const orxSTRING zValue;
94  orxU32 u32Value;
95  orxS32 s32Value;
96  orxU64 u64Value;
97  orxS64 s64Value;
98  orxFLOAT fValue;
99  orxBOOL bValue;
100  };
101 
105 
107 typedef void (orxFASTCALL *orxCOMMAND_FUNCTION)(orxU32 _u32ArgNumber, const orxCOMMAND_VAR *_astArgList, orxCOMMAND_VAR *_pstResult);
108 
109 
112 #define orxCOMMAND_REGISTER_CORE_COMMAND(MODULE, COMMAND, RESULT_NAME, RESULT_TYPE, REQ_PARAM_NUMBER, OPT_PARAM_NUMBER, ...) \
113 do \
114 { \
115  orxCOMMAND_VAR_DEF stResult; \
116  orxCOMMAND_VAR_DEF astParamList[REQ_PARAM_NUMBER + OPT_PARAM_NUMBER + 1] = {{"Dummy", orxCOMMAND_VAR_TYPE_NONE}, __VA_ARGS__}; \
117  orxSTATUS eStatus; \
118  stResult.eType = RESULT_TYPE; \
119  stResult.zName = RESULT_NAME; \
120  eStatus = orxCommand_Register(#MODULE"."#COMMAND, &orx##MODULE##_Command##COMMAND, REQ_PARAM_NUMBER, OPT_PARAM_NUMBER, &astParamList[1], &stResult);\
121  orxASSERT(eStatus != orxSTATUS_FAILURE); \
122 } while(orxFALSE)
123 
124 #define orxCOMMAND_UNREGISTER_CORE_COMMAND(MODULE, COMMAND) \
125 do \
126 { \
127  orxCommand_Unregister(#MODULE"."#COMMAND); \
128 } while(orxFALSE)
129 
130 #define orxCOMMAND_REGISTER(NAME, FUNCTION, RESULT_NAME, RESULT_TYPE, REQ_PARAM_NUMBER, OPT_PARAM_NUMBER, ...) \
131 do \
132 { \
133  orxCOMMAND_VAR_DEF stResult; \
134  orxCOMMAND_VAR_DEF astParamList[REQ_PARAM_NUMBER + OPT_PARAM_NUMBER + 1] = {{"Dummy", orxCOMMAND_VAR_TYPE_NONE}, __VA_ARGS__}; \
135  orxSTATUS eStatus; \
136  stResult.eType = RESULT_TYPE; \
137  stResult.zName = RESULT_NAME; \
138  eStatus = orxCommand_Register(NAME, &FUNCTION, REQ_PARAM_NUMBER, OPT_PARAM_NUMBER, &astParamList[1], &stResult); \
139  orxASSERT(eStatus != orxSTATUS_FAILURE); \
140 } while(orxFALSE)
141 
142 #define orxCOMMAND_UNREGISTER(NAME) \
143 do \
144 { \
145  orxCommand_Unregister(NAME); \
146 } while(orxFALSE)
147 
148 
151 extern orxDLLAPI void orxFASTCALL orxCommand_Setup();
152 
156 extern orxDLLAPI orxSTATUS orxFASTCALL orxCommand_Init();
157 
160 extern orxDLLAPI void orxFASTCALL orxCommand_Exit();
161 
162 
172 extern orxDLLAPI orxSTATUS orxFASTCALL orxCommand_Register(const orxSTRING _zCommand, const orxCOMMAND_FUNCTION _pfnFunction, orxU32 _u32RequiredParamNumber, orxU32 _u32OptionalParamNumber, const orxCOMMAND_VAR_DEF *_astParamList, const orxCOMMAND_VAR_DEF *_pstResult);
173 
178 extern orxDLLAPI orxSTATUS orxFASTCALL orxCommand_Unregister(const orxSTRING _zCommand);
179 
184 extern orxDLLAPI orxBOOL orxFASTCALL orxCommand_IsRegistered(const orxSTRING _zCommand);
185 
186 
193 extern orxDLLAPI orxSTATUS orxFASTCALL orxCommand_AddAlias(const orxSTRING _zAlias, const orxSTRING _zCommand, const orxSTRING _zArgs);
194 
199 extern orxDLLAPI orxSTATUS orxFASTCALL orxCommand_RemoveAlias(const orxSTRING _zAlias);
200 
205 extern orxDLLAPI orxBOOL orxFASTCALL orxCommand_IsAlias(const orxSTRING _zAlias);
206 
207 
212 extern orxDLLAPI const orxSTRING orxFASTCALL orxCommand_GetPrototype(const orxSTRING _zCommand);
213 
220 extern orxDLLAPI const orxSTRING orxFASTCALL orxCommand_GetNext(const orxSTRING _zBase, const orxSTRING _zPrevious, orxU32 *_pu32CommonLength);
221 
222 
228 extern orxDLLAPI orxCOMMAND_VAR *orxFASTCALL orxCommand_Evaluate(const orxSTRING _zCommandLine, orxCOMMAND_VAR *_pstResult);
229 
236 extern orxDLLAPI orxCOMMAND_VAR *orxFASTCALL orxCommand_EvaluateWithGUID(const orxSTRING _zCommandLine, orxU64 _u64GUID, orxCOMMAND_VAR *_pstResult);
237 
245 extern orxDLLAPI orxCOMMAND_VAR *orxFASTCALL orxCommand_Execute(const orxSTRING _zCommand, orxU32 _u32ArgNumber, const orxCOMMAND_VAR *_astArgList, orxCOMMAND_VAR *_pstResult);
246 
247 
254 extern orxDLLAPI orxSTATUS orxFASTCALL orxCommand_ParseNumericalArguments(orxU32 _u32ArgNumber, const orxCOMMAND_VAR *_astArgList, orxCOMMAND_VAR *_astOperandList);
255 
262 extern orxDLLAPI orxU32 orxFASTCALL orxCommand_PrintVar(orxSTRING _zDstString, orxU32 _u32Size, const orxCOMMAND_VAR *_pstVar);
263 
264 
265 #endif /* _orxCOMMAND_H_ */
266 
orxDLLAPI const orxSTRING orxFASTCALL orxCommand_GetPrototype(const orxSTRING _zCommand)
orxVECTOR vValue
Definition: orxCommand.h:92
orxDLLAPI orxSTATUS orxFASTCALL orxCommand_Register(const orxSTRING _zCommand, const orxCOMMAND_FUNCTION _pfnFunction, orxU32 _u32RequiredParamNumber, orxU32 _u32OptionalParamNumber, const orxCOMMAND_VAR_DEF *_astParamList, const orxCOMMAND_VAR_DEF *_pstResult)
orxDLLAPI orxSTATUS orxFASTCALL orxCommand_AddAlias(const orxSTRING _zAlias, const orxSTRING _zCommand, const orxSTRING _zArgs)
orxDLLAPI void orxFASTCALL orxCommand_Exit()
orxDLLAPI orxSTATUS orxFASTCALL orxCommand_RemoveAlias(const orxSTRING _zAlias)
orxDLLAPI void orxFASTCALL orxCommand_Setup()
orxCOMMAND_VAR_TYPE eType
Definition: orxCommand.h:83
orxS64 s64Value
Definition: orxCommand.h:97
orxDLLAPI orxSTATUS orxFASTCALL orxCommand_ParseNumericalArguments(orxU32 _u32ArgNumber, const orxCOMMAND_VAR *_astArgList, orxCOMMAND_VAR *_astOperandList)
orxDLLAPI orxBOOL orxFASTCALL orxCommand_IsRegistered(const orxSTRING _zCommand)
orxDLLAPI orxCOMMAND_VAR *orxFASTCALL orxCommand_EvaluateWithGUID(const orxSTRING _zCommandLine, orxU64 _u64GUID, orxCOMMAND_VAR *_pstResult)
orxDLLAPI orxSTATUS orxFASTCALL orxCommand_Init()
const orxSTRING zName
Definition: orxCommand.h:82
void(orxFASTCALL * orxCOMMAND_FUNCTION)(orxU32 _u32ArgNumber, const orxCOMMAND_VAR *_astArgList, orxCOMMAND_VAR *_pstResult)
Definition: orxCommand.h:107
orxDLLAPI orxCOMMAND_VAR *orxFASTCALL orxCommand_Evaluate(const orxSTRING _zCommandLine, orxCOMMAND_VAR *_pstResult)
orxS32 s32Value
Definition: orxCommand.h:95
orxDLLAPI orxU32 orxFASTCALL orxCommand_PrintVar(orxSTRING _zDstString, orxU32 _u32Size, const orxCOMMAND_VAR *_pstVar)
orxFLOAT fValue
Definition: orxCommand.h:98
orxSTATUS
Definition: orxType.h:256
orxDLLAPI orxBOOL orxFASTCALL orxCommand_IsAlias(const orxSTRING _zAlias)
orxU64 u64Value
Definition: orxCommand.h:96
typedef void(orxFASTCALL *orxMODULE_EXIT_FUNCTION)()
#define orxDLLAPI
Definition: orxDecl.h:370
orxDLLAPI orxCOMMAND_VAR *orxFASTCALL orxCommand_Execute(const orxSTRING _zCommand, orxU32 _u32ArgNumber, const orxCOMMAND_VAR *_astArgList, orxCOMMAND_VAR *_pstResult)
orxDLLAPI const orxSTRING orxFASTCALL orxCommand_GetNext(const orxSTRING _zBase, const orxSTRING _zPrevious, orxU32 *_pu32CommonLength)
orxCOMMAND_VAR_TYPE eType
Definition: orxCommand.h:102
orxDLLAPI orxSTATUS orxFASTCALL orxCommand_Unregister(const orxSTRING _zCommand)
const orxSTRING zValue
Definition: orxCommand.h:93
orxU32 u32Value
Definition: orxCommand.h:94
orxBOOL bValue
Definition: orxCommand.h:99
orxCOMMAND_VAR_TYPE
Definition: orxCommand.h:59

Generated for orx by doxygen 1.8.11