From 46db807ed7e28a30a67430d6fe2eeacc17c647aa Mon Sep 17 00:00:00 2001 From: aidinabedi Date: Sat, 19 Dec 2009 18:23:53 +0000 Subject: [PATCH] added option for dynamic linking --- Shiny/include/ShinyConfig.h | 5 +++++ Shiny/include/ShinyManager.h | 34 +++++++++++++++++----------------- Shiny/include/ShinyNode.h | 10 +++++----- Shiny/include/ShinyOutput.h | 8 ++++---- Shiny/include/ShinyPrereqs.h | 14 +++++++++++++- Shiny/include/ShinyTools.h | 8 ++++---- Shiny/include/ShinyZone.h | 14 +++++++------- 7 files changed, 55 insertions(+), 38 deletions(-) diff --git a/Shiny/include/ShinyConfig.h b/Shiny/include/ShinyConfig.h index 222c8f6..4cdb308 100644 --- a/Shiny/include/ShinyConfig.h +++ b/Shiny/include/ShinyConfig.h @@ -38,6 +38,11 @@ THE SOFTWARE. #define SHINY_IS_COMPILED TRUE #endif +// TODO: +#ifndef SHINY_STATIC_LINK +#define SHINY_STATIC_LINK TRUE +#endif + // if SHINY_LOOKUP_RATE is defined to TRUE then Shiny will record the success of its hash function. This is useful for debugging. Default is FALSE. #ifndef SHINY_LOOKUP_RATE #define SHINY_LOOKUP_RATE FALSE diff --git a/Shiny/include/ShinyManager.h b/Shiny/include/ShinyManager.h index a44d865..66157dc 100644 --- a/Shiny/include/ShinyManager.h +++ b/Shiny/include/ShinyManager.h @@ -93,16 +93,16 @@ SHINY_INLINE void _ShinyManager_appendTicksToCurNode(ShinyManager *self) { self->_lastTick = curTick; } -ShinyNode* _ShinyManager_lookupNode(ShinyManager *self, ShinyNodeCache* a_cache, ShinyZone* a_zone); +SHINY_API ShinyNode* _ShinyManager_lookupNode(ShinyManager *self, ShinyNodeCache* a_cache, ShinyZone* a_zone); -void _ShinyManager_createNodeTable(ShinyManager *self, uint32_t a_count); -void _ShinyManager_resizeNodeTable(ShinyManager *self, uint32_t a_count); +SHINY_API void _ShinyManager_createNodeTable(ShinyManager *self, uint32_t a_count); +SHINY_API void _ShinyManager_resizeNodeTable(ShinyManager *self, uint32_t a_count); -void _ShinyManager_createNodePool(ShinyManager *self, uint32_t a_count); -void _ShinyManager_resizeNodePool(ShinyManager *self, uint32_t a_count); +SHINY_API void _ShinyManager_createNodePool(ShinyManager *self, uint32_t a_count); +SHINY_API void _ShinyManager_resizeNodePool(ShinyManager *self, uint32_t a_count); -ShinyNode* _ShinyManager_createNode(ShinyManager *self, ShinyNodeCache* a_cache, ShinyZone* a_pZone); -void _ShinyManager_insertNode(ShinyManager *self, ShinyNode* a_pNode); +SHINY_API ShinyNode* _ShinyManager_createNode(ShinyManager *self, ShinyNodeCache* a_cache, ShinyZone* a_pZone); +SHINY_API void _ShinyManager_insertNode(ShinyManager *self, ShinyNode* a_pNode); SHINY_INLINE void _ShinyManager_init(ShinyManager *self) { self->_initialized = TRUE; @@ -131,8 +131,8 @@ SHINY_INLINE void _ShinyManager_incLookupSuccess(ShinyManager *self) {} SHINY_INLINE float ShinyManager_getLookupRate(const ShinyManager *self) { return -1; } #endif -void ShinyManager_resetZones(ShinyManager *self); -void ShinyManager_destroyNodes(ShinyManager *self); +SHINY_API void ShinyManager_resetZones(ShinyManager *self); +SHINY_API void ShinyManager_destroyNodes(ShinyManager *self); SHINY_INLINE float ShinyManager_tableUsage(const ShinyManager *self) { return ((float) self->nodeCount) / ((float) self->_tableSize); @@ -172,23 +172,23 @@ SHINY_INLINE void ShinyManager_endCurNode(ShinyManager *self) { // -void ShinyManager_preLoad(ShinyManager *self); +SHINY_API void ShinyManager_preLoad(ShinyManager *self); -void ShinyManager_updateClean(ShinyManager *self); -void ShinyManager_update(ShinyManager *self); +SHINY_API void ShinyManager_updateClean(ShinyManager *self); +SHINY_API void ShinyManager_update(ShinyManager *self); -void ShinyManager_clear(ShinyManager *self); -void ShinyManager_destroy(ShinyManager *self); +SHINY_API void ShinyManager_clear(ShinyManager *self); +SHINY_API void ShinyManager_destroy(ShinyManager *self); SHINY_INLINE void ShinyManager_sortZones(ShinyManager *self) { if (self->rootZone.next) self->rootZone.next = ShinyZone_sortChain(self->rootZone.next); } -const char* ShinyManager_getOutputErrorString(ShinyManager *self); +SHINY_API const char* ShinyManager_getOutputErrorString(ShinyManager *self); -int ShinyManager_outputToFile(ShinyManager *self, const char *a_filename); -void ShinyManager_outputToStream(ShinyManager *self, FILE *stream); +SHINY_API int ShinyManager_outputToFile(ShinyManager *self, const char *a_filename); +SHINY_API void ShinyManager_outputToStream(ShinyManager *self, FILE *stream); #if __cplusplus } // end of extern "C" diff --git a/Shiny/include/ShinyNode.h b/Shiny/include/ShinyNode.h index 6d5bdd6..ea6df94 100644 --- a/Shiny/include/ShinyNode.h +++ b/Shiny/include/ShinyNode.h @@ -85,8 +85,8 @@ SHINY_INLINE void ShinyNode_init(ShinyNode* self, ShinyNode* a_parent, struct _S self->_cache = a_cache; } -void ShinyNode_updateTree(ShinyNode* self, float a_damping); -void ShinyNode_updateTreeClean(ShinyNode* self); +SHINY_API void ShinyNode_updateTree(ShinyNode* self, float a_damping); +SHINY_API void ShinyNode_updateTreeClean(ShinyNode* self); SHINY_INLINE void ShinyNode_destroy(ShinyNode* self) { *(self->_cache) = &_ShinyNode_dummy; @@ -112,11 +112,11 @@ SHINY_INLINE int ShinyNode_isEqual(ShinyNode* self, const ShinyNode* a_parent, c return (self->parent == a_parent && self->zone == a_zone); } -const ShinyNode* ShinyNode_findNextInTree(const ShinyNode* self); +SHINY_API const ShinyNode* ShinyNode_findNextInTree(const ShinyNode* self); -void ShinyNode_clear(ShinyNode* self); +SHINY_API void ShinyNode_clear(ShinyNode* self); -void ShinyNode_enumerateNodes(const ShinyNode* a_node, void (*a_func)(const ShinyNode*)); +SHINY_API void ShinyNode_enumerateNodes(const ShinyNode* a_node, void (*a_func)(const ShinyNode*)); #if __cplusplus } // end of extern "C" diff --git a/Shiny/include/ShinyOutput.h b/Shiny/include/ShinyOutput.h index 76790a8..efcee91 100644 --- a/Shiny/include/ShinyOutput.h +++ b/Shiny/include/ShinyOutput.h @@ -33,11 +33,11 @@ THE SOFTWARE. //----------------------------------------------------------------------------- -int ShinyPrintNodesSize(uint32_t a_count); -int ShinyPrintZonesSize(uint32_t a_count); +SHINY_API int ShinyPrintNodesSize(uint32_t a_count); +SHINY_API int ShinyPrintZonesSize(uint32_t a_count); -void ShinyPrintNodes(char* output, const ShinyNode *a_root); -void ShinyPrintZones(char* output, const ShinyZone *a_root); +SHINY_API void ShinyPrintNodes(char* output, const ShinyNode *a_root); +SHINY_API void ShinyPrintZones(char* output, const ShinyZone *a_root); //----------------------------------------------------------------------------- diff --git a/Shiny/include/ShinyPrereqs.h b/Shiny/include/ShinyPrereqs.h index e416556..dcdc8e2 100644 --- a/Shiny/include/ShinyPrereqs.h +++ b/Shiny/include/ShinyPrereqs.h @@ -46,20 +46,32 @@ THE SOFTWARE. //----------------------------------------------------------------------------- +#if SHINY_STATIC_LINK == TRUE +# define SHINY_API +#else +# define SHINY_API SHINY_EXPORT +#endif + + +//----------------------------------------------------------------------------- #if SHINY_COMPILER == SHINY_COMPILER_MSVC # define SHINY_INLINE __inline # define SHINY_UNUSED +# define SHINY_EXPORT __declspec(dllexport) #elif SHINY_COMPILER == SHINY_COMPILER_GNUC # define SHINY_INLINE inline -# define SHINY_UNUSED __attribute__ ((unused)) +# define SHINY_UNUSED __attribute__((unused)) +# define SHINY_EXPORT __attribute__((dllexport)) #elif SHINY_COMPILER == SHINY_COMPILER_OTHER # define SHINY_INLINE inline # define SHINY_UNUSED +# define SHINY_EXPORT extern #endif + //----------------------------------------------------------------------------- #if SHINY_COMPILER == SHINY_COMPILER_MSVC diff --git a/Shiny/include/ShinyTools.h b/Shiny/include/ShinyTools.h index c21a752..4e3f701 100644 --- a/Shiny/include/ShinyTools.h +++ b/Shiny/include/ShinyTools.h @@ -38,12 +38,12 @@ typedef struct { //----------------------------------------------------------------------------- -const ShinyTimeUnit* ShinyGetTimeUnit(float ticks); +SHINY_API const ShinyTimeUnit* ShinyGetTimeUnit(float ticks); -void ShinyGetTicks(shinytick_t *p); +SHINY_API void ShinyGetTicks(shinytick_t *p); -shinytick_t ShinyGetTickFreq(void); +SHINY_API shinytick_t ShinyGetTickFreq(void); -float ShinyGetTickInvFreq(void); +SHINY_API float ShinyGetTickInvFreq(void); #endif // ifndef SHINY_*_H diff --git a/Shiny/include/ShinyZone.h b/Shiny/include/ShinyZone.h index b0f7c27..3ef4a28 100644 --- a/Shiny/include/ShinyZone.h +++ b/Shiny/include/ShinyZone.h @@ -60,21 +60,21 @@ SHINY_INLINE void ShinyZone_uninit(ShinyZone *self) { self->next = NULL; } -void ShinyZone_preUpdateChain(ShinyZone *first); -void ShinyZone_updateChain(ShinyZone *first, float a_damping); -void ShinyZone_updateChainClean(ShinyZone *first); +SHINY_API void ShinyZone_preUpdateChain(ShinyZone *first); +SHINY_API void ShinyZone_updateChain(ShinyZone *first, float a_damping); +SHINY_API void ShinyZone_updateChainClean(ShinyZone *first); -void ShinyZone_resetChain(ShinyZone *first); +SHINY_API void ShinyZone_resetChain(ShinyZone *first); -ShinyZone* ShinyZone_sortChain(ShinyZone *first); +SHINY_API ShinyZone* ShinyZone_sortChain(ShinyZone *first); SHINY_INLINE float ShinyZone_compare(ShinyZone *a, ShinyZone *b) { return b->data.selfTicks.avg - a->data.selfTicks.avg; } -void ShinyZone_clear(ShinyZone* self); +SHINY_API void ShinyZone_clear(ShinyZone* self); -void ShinyZone_enumerateZones(const ShinyZone* a_zone, void (*a_func)(const ShinyZone*)); +SHINY_API void ShinyZone_enumerateZones(const ShinyZone* a_zone, void (*a_func)(const ShinyZone*)); #if __cplusplus } // end of extern "C"