makiolo

Shiny patch cross boundaries DLL

Jan 30th, 2015
207
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. shiny/include/ShinyMacros.h | 51 +++++++++++++----------
  2. shiny/include/ShinyManager.h | 9 ++--
  3. shiny/include/ShinyNode.h | 2 +-
  4. shiny/include/ShinyPrereqs.h | 16 ++++---
  5. shiny/src/ShinyManager.c | 99 ++++++++++++++++++++++++++------------------
  6. 5 files changed, 104 insertions(+), 73 deletions(-)
  7.  
  8. diff --git a/shiny/include/ShinyMacros.h b/shiny/include/ShinyMacros.h
  9. index cc94af5..c970518 100644
  10. --- a/shiny/include/ShinyMacros.h
  11. +++ b/shiny/include/ShinyMacros.h
  12. @@ -38,59 +38,62 @@ extern "C" {
  13. /*---------------------------------------------------------------------------*/
  14. /* public preprocessors */
  15.  
  16. +#define PROFILE_RUN_ENGINE() \
  17. + ShinyInit()
  18. +
  19. #define PROFILE_UPDATE() \
  20. - ShinyManager_update(&Shiny_instance)
  21. + ShinyManager_update(Shiny_instance)
  22.  
  23. #define PROFILE_SET_DAMPING(floatfrom0to1) \
  24. - Shiny_instance.damping = (floatfrom0to1);
  25. + Shiny_instance->damping = (floatfrom0to1);
  26.  
  27. #define PROFILE_GET_DAMPING() \
  28. - (Shiny_instance.damping)
  29. + (Shiny_instance->damping)
  30.  
  31. #define PROFILE_OUTPUT(filename) \
  32. - ShinyManager_output(&Shiny_instance, (filename))
  33. + ShinyManager_output(Shiny_instance, (filename))
  34.  
  35. #define PROFILE_OUTPUT_STREAM(stream) \
  36. - ShinyManager_outputToStream(&Shiny_instance, (stream))
  37. + ShinyManager_outputToStream(Shiny_instance, (stream))
  38.  
  39. #ifdef __cplusplus
  40. #define PROFILE_GET_TREE_STRING() \
  41. - ShinyManager_outputTreeToString(&Shiny_instance)
  42. + ShinyManager_outputTreeToString(Shiny_instance)
  43.  
  44. #define PROFILE_GET_FLAT_STRING() \
  45. - ShinyManager_outputFlatToString(&Shiny_instance)
  46. + ShinyManager_outputFlatToString(Shiny_instance)
  47. #endif
  48.  
  49. #define PROFILE_DESTROY() \
  50. - ShinyManager_destroy(&Shiny_instance)
  51. + ShinyManager_destroy(Shiny_instance)
  52.  
  53. #define PROFILE_CLEAR() \
  54. - ShinyManager_clear(&Shiny_instance)
  55. + ShinyManager_clear(Shiny_instance)
  56.  
  57. #define PROFILE_SORT_ZONES() \
  58. - ShinyManager_sortZones(&Shiny_instance)
  59. + ShinyManager_sortZones(Shiny_instance)
  60.  
  61.  
  62. /*---------------------------------------------------------------------------*/
  63. /* public preprocessors */
  64.  
  65. #define PROFILE_GET_TOTAL_TICKS_CUR() \
  66. - ShinyData_totalTicksCur(&Shiny_instance.rootZone.data)
  67. + ShinyData_totalTicksCur(Shiny_instance->rootZone.data)
  68.  
  69. #define PROFILE_GET_TOTAL_TICKS() \
  70. - ShinyData_totalTicksAvg(&Shiny_instance.rootZone.data)
  71. + ShinyData_totalTicksAvg(Shiny_instance->rootZone.data)
  72.  
  73. #define PROFILE_GET_PROFILED_TICKS_CUR() \
  74. - (Shiny_instance.rootZone.data.selfTicks.cur)
  75. + (Shiny_instance->rootZone.data.selfTicks.cur)
  76.  
  77. #define PROFILE_GET_PROFILED_TICKS() \
  78. - (Shiny_instance.rootZone.data.selfTicks.avg)
  79. + (Shiny_instance->rootZone.data.selfTicks.avg)
  80.  
  81. #define PROFILE_GET_UNPROFILED_TICKS_CUR() \
  82. - (Shiny_instance.rootZone.data.childTicks.cur)
  83. + (Shiny_instance->rootZone.data.childTicks.cur)
  84.  
  85. #define PROFILE_GET_UNPROFILED_TICKS() \
  86. - (Shiny_instance.rootZone.data.childTicks.avg)
  87. + (Shiny_instance->rootZone.data.childTicks.avg)
  88.  
  89. #define PROFILE_GET_SHARED_TOTAL_TICKS_CUR(name) \
  90. ShinyData_totalTicksCur(&(_PROFILE_ID_ZONE_SHARED(name).data))
  91. @@ -110,18 +113,18 @@ extern "C" {
  92.  
  93. #define PROFILE_IS_SHARED_SELF_BELOW(name, floatfrom0to1) \
  94. ShinyManager_isZoneSelfTimeBelow( \
  95. - &Shiny_instance, _PROFILE_ID_ZONE_SHARED(name), floatfrom0to1)
  96. + Shiny_instance, _PROFILE_ID_ZONE_SHARED(name), floatfrom0to1)
  97.  
  98. #define PROFILE_IS_SHARED_TOTAL_BELOW(name, floatfrom0to1) \
  99. ShinyManager_isZoneTotalTimeBelow( \
  100. - &Shiny_instance, _PROFILE_ID_ZONE_SHARED(name), floatfrom0to1)
  101. + Shiny_instance, _PROFILE_ID_ZONE_SHARED(name), floatfrom0to1)
  102.  
  103.  
  104. /*---------------------------------------------------------------------------*/
  105. /* public preprocessors */
  106.  
  107. #define PROFILE_END() \
  108. - ShinyManager_endCurNode(&Shiny_instance)
  109. + ShinyManager_endCurNode(Shiny_instance)
  110.  
  111.  
  112. /*---------------------------------------------------------------------------*/
  113. @@ -174,6 +177,12 @@ extern "C" {
  114. \
  115. _PROFILE_ZONE_DECLARE(extern, _PROFILE_ID_ZONE_SHARED(name))
  116.  
  117. +/*---------------------------------------------------------------------------*/
  118. +/* public preprocessors */
  119. +
  120. +#define PROFILE_SHARED_API(api_other_dll, name ) \
  121. + \
  122. + _PROFILE_ZONE_DECLARE(api_other_dll, _PROFILE_ID_ZONE_SHARED(name))
  123.  
  124. /*---------------------------------------------------------------------------*/
  125. /* public preprocessors */
  126. @@ -207,7 +216,7 @@ extern "C" {
  127.  
  128. #if SHINY_HAS_ENABLED == TRUE
  129. #define PROFILE_SET_ENABLED( boolean ) \
  130. - Shiny_instance.enabled = boolean
  131. + Shiny_instance->enabled = boolean
  132. #endif
  133.  
  134.  
  135. @@ -255,7 +264,7 @@ extern "C" {
  136. \
  137. do { \
  138. static ShinyNodeCache cache = &_ShinyNode_dummy; \
  139. - ShinyManager_lookupAndBeginNode(&Shiny_instance, &cache, &id); \
  140. + ShinyManager_lookupAndBeginNode(Shiny_instance, &cache, &id); \
  141. } while(0)
  142.  
  143. /*---------------------------------------------------------------------------*/
  144. diff --git a/shiny/include/ShinyManager.h b/shiny/include/ShinyManager.h
  145. index 44638ef..99202c7 100644
  146. --- a/shiny/include/ShinyManager.h
  147. +++ b/shiny/include/ShinyManager.h
  148. @@ -80,13 +80,12 @@ typedef struct {
  149. int _firstUpdate;
  150. } ShinyManager;
  151.  
  152. -
  153. /*---------------------------------------------------------------------------*/
  154.  
  155. -extern ShinyNode* _ShinyManager_dummyNodeTable[];
  156. -
  157. -extern ShinyManager Shiny_instance;
  158. +SHINY_API void ShinyInit();
  159.  
  160. +SHINY_API ShinyNode* _ShinyManager_dummyNodeTable[];
  161. +SHINY_API ShinyManager* Shiny_instance;
  162.  
  163. /*---------------------------------------------------------------------------*/
  164.  
  165. @@ -269,7 +268,7 @@ class ShinyEndNodeOnDestruction {
  166. public:
  167.  
  168. SHINY_INLINE ~ShinyEndNodeOnDestruction() {
  169. - ShinyManager_endCurNode(&Shiny_instance);
  170. + ShinyManager_endCurNode(Shiny_instance);
  171. }
  172. };
  173.  
  174. diff --git a/shiny/include/ShinyNode.h b/shiny/include/ShinyNode.h
  175. index 11ae004..b492b3c 100644
  176. --- a/shiny/include/ShinyNode.h
  177. +++ b/shiny/include/ShinyNode.h
  178. @@ -61,7 +61,7 @@ typedef struct _ShinyNode {
  179.  
  180. /*---------------------------------------------------------------------------*/
  181.  
  182. -extern ShinyNode _ShinyNode_dummy;
  183. +SHINY_API ShinyNode _ShinyNode_dummy;
  184.  
  185.  
  186. /*---------------------------------------------------------------------------*/
  187. diff --git a/shiny/include/ShinyPrereqs.h b/shiny/include/ShinyPrereqs.h
  188. index cb458d1..befca71 100644
  189. --- a/shiny/include/ShinyPrereqs.h
  190. +++ b/shiny/include/ShinyPrereqs.h
  191. @@ -97,15 +97,21 @@ extern "C" {
  192. typedef struct _ShinyNode* ShinyNodeTable;
  193. #endif
  194.  
  195. -
  196. /*---------------------------------------------------------------------------*/
  197.  
  198. -#if SHINY_STATIC_LINK == TRUE
  199. -# define SHINY_API
  200. +#if defined(_WIN32)
  201. +#ifdef Shiny_EXPORTS
  202. +#define SHINY_API __declspec(dllexport)
  203. +#else
  204. +#ifndef Shiny_STATIC
  205. +#define SHINY_API __declspec(dllimport)
  206. #else
  207. -# define SHINY_API SHINY_EXPORT
  208. +#define SHINY_API
  209. +#endif
  210. +#endif
  211. +#else
  212. +#define SHINY_API
  213. #endif
  214. -
  215.  
  216. /*---------------------------------------------------------------------------*/
  217.  
  218. diff --git a/shiny/src/ShinyManager.c b/shiny/src/ShinyManager.c
  219. index 47f6e5a..1c24892 100644
  220. --- a/shiny/src/ShinyManager.c
  221. +++ b/shiny/src/ShinyManager.c
  222. @@ -38,47 +38,6 @@ THE SOFTWARE.
  223.  
  224. /*---------------------------------------------------------------------------*/
  225.  
  226. -ShinyManager Shiny_instance = {
  227. -#if SHINY_HAS_ENABLED == TRUE
  228. - /* enabled = */ false,
  229. -#endif
  230. - /* _lastTick = */ 0,
  231. - /* _curNode = */ &Shiny_instance.rootNode,
  232. - /* _tableMask = */ 0,
  233. - /* _nodeTable = */ _ShinyManager_dummyNodeTable,
  234. -#if SHINY_LOOKUP_RATE == TRUE
  235. - /* _lookupCount = */ 0,
  236. - /* _lookupSuccessCount = */ 0,
  237. -#endif
  238. - /* _tableSize = */ 1,
  239. - /* nodeCount = */ 1,
  240. - /* zoneCount = */ 1,
  241. - /* _lastZone = */ &Shiny_instance.rootZone,
  242. - /* _lastNodePool = */ NULL,
  243. - /* _firstNodePool = */ NULL,
  244. - /* rootNode = */ {
  245. - /* _last = */ { 0, 0 },
  246. - /* zone = */ &Shiny_instance.rootZone,
  247. - /* parent = */ &Shiny_instance.rootNode,
  248. - /* nextSibling = */ NULL,
  249. - /* firstChild = */ NULL,
  250. - /* lastChild = */ NULL,
  251. - /* childCount = */ 0,
  252. - /* entryLevel = */ 0,
  253. - /* _cache = */ NULL,
  254. - /* data = */ { { 0, 0 }, { 0, 0 }, { 0, 0 } }
  255. - },
  256. - /* rootZone = */ {
  257. - /* next = */ NULL,
  258. - /* _state = */ SHINY_ZONE_STATE_HIDDEN,
  259. - /* name = */ "<unprofiled>",
  260. - /* data = */ { { 0, 0 }, { 0, 0 }, { 0, 0 } }
  261. - },
  262. - /* damping = */ 0.9f,
  263. - /* _initialized = */ FALSE,
  264. - /* _firstUpdate = */ TRUE
  265. -};
  266. -
  267. ShinyNode* _ShinyManager_dummyNodeTable[] = { NULL };
  268.  
  269.  
  270. @@ -442,4 +401,62 @@ void ShinyManager_outputToStream(ShinyManager *self, FILE *a_stream) {
  271. #endif
  272. }
  273.  
  274. +ShinyManager* Shiny_instance = NULL;
  275. +
  276. +void ShinyInit()
  277. +{
  278. + Shiny_instance = malloc(sizeof(ShinyManager));
  279. +#if SHINY_HAS_ENABLED == TRUE
  280. + Shiny_instance->enabled = false;
  281. +#endif
  282. +
  283. +#if SHINY_HAS_ENABLED == TRUE
  284. + Shiny_instance->enabled = false;
  285. +#endif
  286. + Shiny_instance->_lastTick = 0;
  287. + Shiny_instance->_curNode = &Shiny_instance->rootNode;
  288. + Shiny_instance->_tableMask = 0;
  289. + Shiny_instance->_nodeTable = &_ShinyManager_dummyNodeTable;
  290. +#if SHINY_LOOKUP_RATE == TRUE
  291. + Shiny_instance->_lookupCount = 0;
  292. + Shiny_instance->_lookupSuccessCount = 0;
  293. +#endif
  294. + Shiny_instance->_tableSize = 1;
  295. + Shiny_instance->nodeCount = 1;
  296. + Shiny_instance->zoneCount = 1;
  297. + Shiny_instance->_lastZone = &Shiny_instance->rootZone;
  298. + Shiny_instance->_lastNodePool = NULL;
  299. + Shiny_instance->_firstNodePool = NULL;
  300. + Shiny_instance->rootNode._last.entryCount = 0;
  301. + Shiny_instance->rootNode._last.selfTicks = 0;
  302. + Shiny_instance->rootNode.zone = &Shiny_instance->rootZone;
  303. + Shiny_instance->rootNode.parent = &Shiny_instance->rootNode;
  304. + Shiny_instance->rootNode.nextSibling = NULL;
  305. + Shiny_instance->rootNode.firstChild = NULL;
  306. + Shiny_instance->rootNode.lastChild = NULL;
  307. + Shiny_instance->rootNode.childCount = 0;
  308. + Shiny_instance->rootNode.entryLevel = 0;
  309. + Shiny_instance->rootNode._cache = NULL;
  310. + Shiny_instance->rootNode.data.childTicks.avg = 0;
  311. + Shiny_instance->rootNode.data.childTicks.cur = 0;
  312. + Shiny_instance->rootNode.data.entryCount.avg = 0;
  313. + Shiny_instance->rootNode.data.entryCount.cur = 0;
  314. + Shiny_instance->rootNode.data.selfTicks.avg = 0;
  315. + Shiny_instance->rootNode.data.selfTicks.cur = 0;
  316. +
  317. + Shiny_instance->rootZone.next = NULL;
  318. + Shiny_instance->rootZone._state = SHINY_ZONE_STATE_HIDDEN;
  319. + Shiny_instance->rootZone.name = "<unprofiled>";
  320. + Shiny_instance->rootZone.data.childTicks.avg = 0;
  321. + Shiny_instance->rootZone.data.childTicks.cur = 0;
  322. + Shiny_instance->rootZone.data.entryCount.avg = 0;
  323. + Shiny_instance->rootZone.data.entryCount.cur = 0;
  324. + Shiny_instance->rootZone.data.selfTicks.avg = 0;
  325. + Shiny_instance->rootZone.data.selfTicks.cur = 0;
  326. +
  327. + Shiny_instance->damping = 0.9f;
  328. + Shiny_instance->_initialized = FALSE;
  329. + Shiny_instance->_firstUpdate = TRUE;
  330. +}
  331. +
  332. #endif /* if SHINY_IS_COMPILED == TRUE */
RAW Paste Data