orx 1.16
Portable Game Engine
Loading...
Searching...
No Matches
orxPluginUser.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
32
41
42
43#ifndef _orxPLUGIN_USER_H_
44#define _orxPLUGIN_USER_H_
45
46
47#include "orxInclude.h"
48
51
52#include "memory/orxMemory.h"
53#include "utils/orxString.h"
54
55
56/*********************************************
57 Constants
58 *********************************************/
59
62
63
64/* Defines a user plugin init entry function (that take an entry mode argument and return an orxSTATUS value) */
65#define orxPLUGIN_DECLARE_INIT_ENTRY_POINT(ENTRY_FUNCTION) \
66extern orxIMPORT orxDLLEXPORT orxSTATUS orxPLUGIN_K_INIT_FUNCTION_NAME(orxS32 *_ps32Number, orxPLUGIN_USER_FUNCTION_INFO **_ppstInfo) \
67{ \
68 orxSTATUS eResult; \
69 \
70 /* Calls entry point function */ \
71 eResult = ((orxPLUGIN_ENTRY_POINT)ENTRY_FUNCTION)(orxPLUGIN_ENTRY_MODE_INIT); \
72 \
73 /* Updates parameters */ \
74 *_ps32Number = 0; \
75 *_ppstInfo = orxNULL; \
76 \
77 /* Done! */ \
78 return eResult; \
79}
80
81/* Defines a user plugin exit entry function (that take an entry mode argument and return an orxSTATUS value) */
82#define orxPLUGIN_DECLARE_EXIT_ENTRY_POINT(ENTRY_FUNCTION) \
83extern orxIMPORT orxDLLEXPORT orxSTATUS orxPLUGIN_K_EXIT_FUNCTION_NAME() \
84{ \
85 /* Done! */ \
86 return ((orxPLUGIN_ENTRY_POINT)ENTRY_FUNCTION)(orxPLUGIN_ENTRY_MODE_EXIT); \
87}
88
89/* Defines a user plugin swap entry function (that take an entry mode argument and return an orxSTATUS value) */
90#define orxPLUGIN_DECLARE_SWAP_ENTRY_POINT(ENTRY_FUNCTION) \
91extern orxIMPORT orxDLLEXPORT orxSTATUS orxPLUGIN_K_SWAP_FUNCTION_NAME(orxPLUGIN_ENTRY_MODE _eMode) \
92{ \
93 /* Done! */ \
94 return ((orxPLUGIN_ENTRY_POINT)ENTRY_FUNCTION)(_eMode); \
95}
96
97/* Defines a user plugin entry function (that take an entry mode argument and return an orxSTATUS value) */
98#define orxPLUGIN_DECLARE_ENTRY_POINT(ENTRY_FUNCTION) \
99orxPLUGIN_DECLARE_INIT_ENTRY_POINT(ENTRY_FUNCTION); \
100orxPLUGIN_DECLARE_EXIT_ENTRY_POINT(ENTRY_FUNCTION); \
101orxPLUGIN_DECLARE_SWAP_ENTRY_POINT(ENTRY_FUNCTION);
102
103
104/*********************************************
105 Structures
106 *********************************************/
107
108/* Macro for Structure Handling */
109#define _orxPLUGIN_USER_FUNCTION_ADD_LOW_LEVEL(FUNCTION, FUNCTION_ID, NAME, ARGS) \
110 if(u32UserPluginFunctionCount < u32UserPluginFunctionMaxNumber) \
111 { \
112 pstUserPluginFunctionInfo[u32UserPluginFunctionCount].pfnFunction = (orxPLUGIN_FUNCTION) FUNCTION; \
113 pstUserPluginFunctionInfo[u32UserPluginFunctionCount].eFunctionID = FUNCTION_ID; \
114 pstUserPluginFunctionInfo[u32UserPluginFunctionCount].zFunctionName = #NAME; \
115 orxString_NCopy(pstUserPluginFunctionInfo[u32UserPluginFunctionCount].zFunctionArgs, ARGS, orxPLUGIN_KU32_FUNCTION_ARG_SIZE - 1); \
116 pstUserPluginFunctionInfo[u32UserPluginFunctionCount].zFunctionArgs[orxPLUGIN_KU32_FUNCTION_ARG_SIZE - 1] = orxCHAR_NULL; \
117 u32UserPluginFunctionCount++; \
118 } \
119 else \
120 { \
121 /* Logs message */ \
122 orxDEBUG_PRINT(orxDEBUG_LEVEL_SYSTEM, "Maximum number of plugin functions reached."); \
123 }
124
125#define orxPLUGIN_USER_FUNCTION_START(STRUCTURE) \
126{ \
127 orxU32 u32UserPluginFunctionCount = 0; \
128 orxU32 u32UserPluginFunctionMaxNumber = sizeof(STRUCTURE) / sizeof(orxPLUGIN_USER_FUNCTION_INFO); \
129 orxPLUGIN_USER_FUNCTION_INFO *pstUserPluginFunctionInfo = STRUCTURE; \
130 orxMemory_Zero(pstUserPluginFunctionInfo, u32UserPluginFunctionMaxNumber * sizeof(orxPLUGIN_USER_FUNCTION_INFO));
131
132#define orxPLUGIN_USER_FUNCTION_ADD(FUNCTION, ARGS, PLUGIN_ID, FUNCTION_BASE_ID, NAME) \
133 _orxPLUGIN_USER_FUNCTION_ADD_LOW_LEVEL(&FUNCTION, \
134 orxPLUGIN_MAKE_FUNCTION_ID(PLUGIN_ID, FUNCTION_BASE_ID), \
135 NAME, \
136 ARGS)
137
138#define orxPLUGIN_USER_FUNCTION_END(NUMBER_ADDRESS, STRUCTURE_ADDRESS) \
139 *NUMBER_ADDRESS = u32UserPluginFunctionCount; \
140 *STRUCTURE_ADDRESS = pstUserPluginFunctionInfo; \
141}
142
143#define orxPLUGIN_USER_CORE_FUNCTION_START(PLUGIN_SUFFIX) \
144 static orxPLUGIN_USER_FUNCTION_INFO sau32##PLUGIN_SUFFIX##_Function[orxPLUGIN_FUNCTION_BASE_ID_##PLUGIN_SUFFIX##_NUMBER]; \
145 extern orxIMPORT orxDLLEXPORT orxSTATUS orxPLUGIN_K_CORE_INIT_FUNCTION_NAME(PLUGIN_SUFFIX)(orxS32 *_ps32Number, orxPLUGIN_USER_FUNCTION_INFO **_ppstInfo) \
146 { \
147 orxSTATUS eResult = orxSTATUS_SUCCESS; \
148 orxPLUGIN_USER_FUNCTION_START(sau32##PLUGIN_SUFFIX##_Function);
149
150#define orxPLUGIN_USER_CORE_FUNCTION_ADD(FUNCTION, PLUGIN_SUFFIX, NAME_SUFFIX) \
151 _orxPLUGIN_USER_FUNCTION_ADD_LOW_LEVEL(&FUNCTION, \
152 orxPLUGIN_MAKE_CORE_FUNCTION_ID(orxPLUGIN_CORE_ID_##PLUGIN_SUFFIX, orxPLUGIN_FUNCTION_BASE_ID_##PLUGIN_SUFFIX##_##NAME_SUFFIX), \
153 PLUGIN_SUFFIX##_##NAME_SUFFIX, \
154 orxSTRING_EMPTY)
155
156#define orxPLUGIN_USER_CORE_FUNCTION_END() \
157 orxPLUGIN_USER_FUNCTION_END(_ps32Number, _ppstInfo); \
158 return eResult; \
159 }
160
161#endif /* _orxPLUGIN_USER_H_ */
162
orxSTATUS(orxFASTCALL * orxPLUGIN_ENTRY_POINT)(orxPLUGIN_ENTRY_MODE _eMode)
orxPLUGIN_ENTRY_MODE
orxSTATUS
Definition orxType.h:270

Generated for orx by doxygen 1.8.11