orx  stable
Portable Game Engine
orxPluginUser.h
Go to the documentation of this file.
1 /* Orx - Portable Game Engine
2  *
3  * Copyright (c) 2008-2017 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 
43 #ifndef _orxPLUGIN_USER_H_
44 #define _orxPLUGIN_USER_H_
45 
46 
47 #include "orxInclude.h"
48 
49 #include "plugin/orxPluginType.h"
51 
52 #include "memory/orxMemory.h"
53 #include "utils/orxString.h"
54 
55 
56 /*********************************************
57  Constants
58  *********************************************/
59 
60 /* Defines a user plugin entry function (that takes no arguments and return an orxSTATUS value) */
61 #define orxPLUGIN_DECLARE_ENTRY_POINT(ENTRY_FUNCTION) \
62 extern orxIMPORT orxDLLEXPORT orxSTATUS orxPLUGIN_K_INIT_FUNCTION_NAME(orxS32 *_ps32Number, orxPLUGIN_USER_FUNCTION_INFO **_ppstInfo) \
63 { \
64  orxSTATUS eResult; \
65  \
66  /* Calls entry point function */ \
67  eResult = ENTRY_FUNCTION(); \
68  \
69  /* Updates parameters */ \
70  *_ps32Number = 0; \
71  *_ppstInfo = orxNULL; \
72  \
73  /* Done! */ \
74  return eResult; \
75 }
76 
77 
78 /*********************************************
79  Structures
80  *********************************************/
81 
82 /* Macro for Structure Handling */
83 #define _orxPLUGIN_USER_FUNCTION_ADD_LOW_LEVEL(FUNCTION, FUNCTION_ID, NAME, ARGS) \
84  if(u32UserPluginFunctionCounter < u32UserPluginFunctionMaxNumber) \
85  { \
86  pstUserPluginFunctionInfo[u32UserPluginFunctionCounter].pfnFunction = (orxPLUGIN_FUNCTION) FUNCTION; \
87  pstUserPluginFunctionInfo[u32UserPluginFunctionCounter].eFunctionID = FUNCTION_ID; \
88  pstUserPluginFunctionInfo[u32UserPluginFunctionCounter].zFunctionName = #NAME; \
89  orxString_NCopy(pstUserPluginFunctionInfo[u32UserPluginFunctionCounter].zFunctionArgs, ARGS, orxPLUGIN_KU32_FUNCTION_ARG_SIZE - 1); \
90  pstUserPluginFunctionInfo[u32UserPluginFunctionCounter].zFunctionArgs[orxPLUGIN_KU32_FUNCTION_ARG_SIZE - 1] = orxCHAR_NULL; \
91  u32UserPluginFunctionCounter++; \
92  } \
93  else \
94  { \
95  /* Logs message */ \
96  orxDEBUG_PRINT(orxDEBUG_LEVEL_SYSTEM, "Maximum number of plugin functions reached."); \
97  }
98 
99 #define orxPLUGIN_USER_FUNCTION_START(STRUCTURE) \
100 { \
101  orxU32 u32UserPluginFunctionCounter = 0; \
102  orxU32 u32UserPluginFunctionMaxNumber = sizeof(STRUCTURE) / sizeof(orxPLUGIN_USER_FUNCTION_INFO); \
103  orxPLUGIN_USER_FUNCTION_INFO *pstUserPluginFunctionInfo = STRUCTURE; \
104  orxMemory_Zero(pstUserPluginFunctionInfo, u32UserPluginFunctionMaxNumber * sizeof(orxPLUGIN_USER_FUNCTION_INFO));
105 
106 #define orxPLUGIN_USER_FUNCTION_ADD(FUNCTION, ARGS, PLUGIN_ID, FUNCTION_BASE_ID, NAME) \
107  _orxPLUGIN_USER_FUNCTION_ADD_LOW_LEVEL(&FUNCTION, \
108  orxPLUGIN_MAKE_FUNCTION_ID(PLUGIN_ID, FUNCTION_BASE_ID), \
109  NAME, \
110  ARGS)
111 
112 #define orxPLUGIN_USER_FUNCTION_END(NUMBER_ADDRESS, STRUCTURE_ADDRESS) \
113  *NUMBER_ADDRESS = u32UserPluginFunctionCounter; \
114  *STRUCTURE_ADDRESS = pstUserPluginFunctionInfo; \
115 }
116 
117 #define orxPLUGIN_USER_CORE_FUNCTION_START(PLUGIN_SUFFIX) \
118  static orxPLUGIN_USER_FUNCTION_INFO sau32##PLUGIN_SUFFIX##_Function[orxPLUGIN_FUNCTION_BASE_ID_##PLUGIN_SUFFIX##_NUMBER]; \
119  extern orxIMPORT orxDLLEXPORT orxSTATUS orxPLUGIN_K_CORE_INIT_FUNCTION_NAME(PLUGIN_SUFFIX)(orxS32 *_ps32Number, orxPLUGIN_USER_FUNCTION_INFO **_ppstInfo) \
120  { \
121  orxSTATUS eResult = orxSTATUS_SUCCESS; \
122  orxPLUGIN_USER_FUNCTION_START(sau32##PLUGIN_SUFFIX##_Function);
123 
124 #define orxPLUGIN_USER_CORE_FUNCTION_ADD(FUNCTION, PLUGIN_SUFFIX, NAME_SUFFIX) \
125  _orxPLUGIN_USER_FUNCTION_ADD_LOW_LEVEL(&FUNCTION, \
126  orxPLUGIN_MAKE_CORE_FUNCTION_ID(orxPLUGIN_CORE_ID_##PLUGIN_SUFFIX, orxPLUGIN_FUNCTION_BASE_ID_##PLUGIN_SUFFIX##_##NAME_SUFFIX), \
127  PLUGIN_SUFFIX##_##NAME_SUFFIX, \
128  orxSTRING_EMPTY)
129 
130 #define orxPLUGIN_USER_CORE_FUNCTION_END() \
131  orxPLUGIN_USER_FUNCTION_END(_ps32Number, _ppstInfo); \
132  return eResult; \
133  }
134 
135 #endif /* _orxPLUGIN_USER_H_ */
136 

Generated for orx by doxygen 1.5.6