orx 1.16
Portable Game Engine
Loading...
Searching...
No Matches
orxCommand.h
Go to the documentation of this file.
1/* Orx - Portable Game Engine
2 *
3 * Copyright (c) 2008- 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
31
39
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 '"' /**< Block marker character */
51#define orxCOMMAND_KC_PUSH_MARKER '>' /**< Push marker character */
52#define orxCOMMAND_KC_POP_MARKER '<' /**< Pop marker character */
53#define orxCOMMAND_KC_GUID_MARKER '^' /**< GUID marker character */
54#define orxCOMMAND_KC_SEPARATOR ',' /**< Command separator character */
55
56
59typedef enum __orxCOMMAND_VAR_TYPE_t
60{
61 orxCOMMAND_VAR_TYPE_STRING = 0,
62 orxCOMMAND_VAR_TYPE_FLOAT,
63 orxCOMMAND_VAR_TYPE_S32,
64 orxCOMMAND_VAR_TYPE_U32,
65 orxCOMMAND_VAR_TYPE_S64,
66 orxCOMMAND_VAR_TYPE_U64,
67 orxCOMMAND_VAR_TYPE_BOOL,
68 orxCOMMAND_VAR_TYPE_VECTOR,
69 orxCOMMAND_VAR_TYPE_NUMERIC,
70
71 orxCOMMAND_VAR_TYPE_NUMBER,
72
73 orxCOMMAND_VAR_TYPE_NONE = orxENUM_NONE
74
75} orxCOMMAND_VAR_TYPE;
76
77
80typedef struct __orxCOMMAND_VAR_DEF_t
81{
82 const orxSTRING zName; /**< Name : 4 */
83 orxCOMMAND_VAR_TYPE eType; /**< Type : 8 */
84
85} orxCOMMAND_VAR_DEF;
86
88typedef struct __orxCOMMAND_VAR_t
89{
90 union
91 {
92 orxVECTOR vValue; /**< Vector value : 12 */
93 const orxSTRING zValue; /**< String value : 4 */
94 orxU32 u32Value; /**< U32 value : 4 */
95 orxS32 s32Value; /**< S32 value : 4 */
96 orxU64 u64Value; /**< U64 value : 8 */
97 orxS64 s64Value; /**< S64 value : 8 */
98 orxFLOAT fValue; /**< Float value : 4 */
99 orxBOOL bValue; /**< Bool value : 4 */
100 };
101
102 orxCOMMAND_VAR_TYPE eType; /**< Type : 16 */
103
104} orxCOMMAND_VAR;
105
107typedef 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, ...) \
113do \
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) \
125do \
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, ...) \
131do \
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) \
143do \
144{ \
145 orxCommand_Unregister(NAME); \
146} while(orxFALSE)
147
148
151extern orxDLLAPI void orxFASTCALL orxCommand_Setup();
152
156extern orxDLLAPI orxSTATUS orxFASTCALL orxCommand_Init();
157
160extern orxDLLAPI void orxFASTCALL orxCommand_Exit();
161
162
172extern 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
178extern orxDLLAPI orxSTATUS orxFASTCALL orxCommand_Unregister(const orxSTRING _zCommand);
179
184extern orxDLLAPI orxBOOL orxFASTCALL orxCommand_IsRegistered(const orxSTRING _zCommand);
185
186
193extern orxDLLAPI orxSTATUS orxFASTCALL orxCommand_AddAlias(const orxSTRING _zAlias, const orxSTRING _zCommand, const orxSTRING _zArgs);
194
199extern orxDLLAPI orxSTATUS orxFASTCALL orxCommand_RemoveAlias(const orxSTRING _zAlias);
200
205extern orxDLLAPI orxBOOL orxFASTCALL orxCommand_IsAlias(const orxSTRING _zAlias);
206
207
212extern orxDLLAPI const orxSTRING orxFASTCALL orxCommand_GetPrototype(const orxSTRING _zCommand);
213
220extern orxDLLAPI const orxSTRING orxFASTCALL orxCommand_GetNext(const orxSTRING _zBase, const orxSTRING _zPrevious, orxU32 *_pu32CommonLength);
221
222
228extern orxDLLAPI orxCOMMAND_VAR *orxFASTCALL orxCommand_Evaluate(const orxSTRING _zCommandLine, orxCOMMAND_VAR *_pstResult);
229
236extern orxDLLAPI orxCOMMAND_VAR *orxFASTCALL orxCommand_EvaluateWithGUID(const orxSTRING _zCommandLine, orxU64 _u64GUID, orxCOMMAND_VAR *_pstResult);
237
245extern orxDLLAPI orxCOMMAND_VAR *orxFASTCALL orxCommand_Execute(const orxSTRING _zCommand, orxU32 _u32ArgNumber, const orxCOMMAND_VAR *_astArgList, orxCOMMAND_VAR *_pstResult);
246
247
254extern orxDLLAPI orxSTATUS orxFASTCALL orxCommand_ParseNumericalArguments(orxU32 _u32ArgNumber, const orxCOMMAND_VAR *_astArgList, orxCOMMAND_VAR *_astOperandList);
255
262extern orxDLLAPI orxU32 orxFASTCALL orxCommand_PrintVar(orxSTRING _zDstString, orxU32 _u32Size, const orxCOMMAND_VAR *_pstVar);
263
264
265#endif /* _orxCOMMAND_H_ */
266

Generated for orx by doxygen 1.8.11