Houdini Engine 3.0
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
HAPI_API.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * Produced by:
7  * Side Effects Software Inc
8  * 123 Front Street West, Suite 1401
9  * Toronto, Ontario
10  * Canada M5J 2M2
11  * 416-504-9876
12  *
13  * COMMENTS:
14  */
15 
16 #ifndef __HAPI_API_h__
17 #define __HAPI_API_h__
18 
19 // Helper macros.
20 #if defined( __GNUC__ )
21  #define HAPI_IS_GCC_GE( MAJOR, MINOR ) \
22  ( __GNUC__ > MAJOR || (__GNUC__ == MAJOR && __GNUC_MINOR__ >= MINOR) )
23 #else
24  #define HAPI_IS_GCC_GE( MAJOR, MINOR ) 0
25 #endif // defined( __GNUC__ )
26 #define HAPI_TO_STRING_( a ) # a
27 #define HAPI_TO_STRING( a ) HAPI_TO_STRING_( a )
28 
29 // Mark function as deprecated and may be removed in the future.
30 // @note This qualifier can only appear in function declarations.
31 #ifdef HAPI_SUPPRESS_DEPRECATIONS
32  #define HAPI_DEPRECATED( hapi_ver, houdini_ver )
33  #define HAPI_DEPRECATED_REPLACE( hapi_ver, houdini_ver, replacement )
34 #elif defined( GCC3 )
35  #if HAPI_IS_GCC_GE( 4, 6 ) || defined( __clang__ )
36  #define HAPI_DEPRECATED( hapi_ver, houdini_ver ) \
37  __attribute__( ( deprecated( \
38  "Deprecated since version HAPI " HAPI_TO_STRING( hapi_ver ) \
39  ", Houdini " HAPI_TO_STRING( houdini_ver ) ) ) )
40  #define HAPI_DEPRECATED_REPLACE( hapi_ver, houdini_ver, replacement ) \
41  __attribute__( ( deprecated( \
42  "Deprecated since version HAPI " HAPI_TO_STRING( hapi_ver ) \
43  ", Houdini " HAPI_TO_STRING( houdini_ver ) ". Use " \
44  HAPI_TO_STRING( replacement ) " instead." ) ) )
45  #else
46  #define HAPI_DEPRECATED( hapi_ver, houdini_ver ) \
47  __attribute__( ( deprecated ) )
48  #define HAPI_DEPRECATED_REPLACE( hapi_ver, houdini_ver, replacement ) \
49  __attribute__( ( deprecated ) )
50  #endif
51 #elif defined( _MSC_VER )
52  #define HAPI_DEPRECATED( hapi_ver, houdini_ver ) \
53  __declspec( deprecated( \
54  "Deprecated since version HAPI " HAPI_TO_STRING( hapi_ver ) \
55  ", Houdini " HAPI_TO_STRING( houdini_ver ) ) )
56  #define HAPI_DEPRECATED_REPLACE( hapi_ver, houdini_ver, replacement ) \
57  __declspec( deprecated( \
58  "Deprecated since version HAPI " HAPI_TO_STRING( hapi_ver ) \
59  ", Houdini " HAPI_TO_STRING( houdini_ver ) ". Use " \
60  HAPI_TO_STRING( replacement ) " instead." ) )
61 #else
62  #define HAPI_DEPRECATED( hapi_ver, houdini_ver )
63  #define HAPI_DEPRECATED_REPLACE( hapi_ver, houdini_ver, replacement )
64 #endif
65 
66 #if defined( WIN32 ) && !defined( MAKING_STATIC )
67  #define HAPI_VISIBILITY_EXPORT __declspec( dllexport )
68  #define HAPI_VISIBILITY_IMPORT __declspec( dllimport )
69  #define HAPI_VISIBILITY_EXPORT_TINST HAPI_VISIBILITY_EXPORT
70  #define HAPI_VISIBILITY_IMPORT_TINST HAPI_VISIBILITY_IMPORT
71 #elif defined(__GNUC__) && HAPI_IS_GCC_GE( 4, 2 ) && !defined( MAKING_STATIC )
72  #define HAPI_VISIBILITY_EXPORT __attribute__( ( visibility( "default" ) ) )
73  #define HAPI_VISIBILITY_IMPORT __attribute__( ( visibility( "default" ) ) )
74  #define HAPI_VISIBILITY_EXPORT_TINST
75  #define HAPI_VISIBILITY_IMPORT_TINST
76 #else
77  #define HAPI_VISIBILITY_EXPORT
78  #define HAPI_VISIBILITY_IMPORT
79  #define HAPI_VISIBILITY_EXPORT_TINST
80  #define HAPI_VISIBILITY_IMPORT_TINST
81 #endif
82 
83 #ifdef HAPI_EXPORTS
84  #define HAPI_API HAPI_VISIBILITY_EXPORT
85 #else
86  #define HAPI_API HAPI_VISIBILITY_IMPORT
87 #endif // HAPI_EXPORTS
88 
89 #if defined( WIN32 )
90  #define HAPI_CALL __cdecl
91 #else
92  #define HAPI_CALL
93 #endif // defined( WIN32 )
94 
95 #ifdef __cplusplus
96  #define HAPI_EXTERN_C extern "C"
97 #else
98  #define HAPI_EXTERN_C
99 #endif // __cplusplus
100 
101 #define HAPI_RETURN HAPI_Result HAPI_CALL
102 
103 #define HAPI_DECL_RETURN( r ) HAPI_EXTERN_C HAPI_API r HAPI_CALL
104 #define HAPI_DECL_DEPRECATED( hapi_ver, houdini_ver ) \
105  HAPI_EXTERN_C \
106  HAPI_DEPRECATED( hapi_ver, houdini_ver ) \
107  HAPI_API \
108  HAPI_RETURN
109 #define HAPI_DECL_DEPRECATED_REPLACE( hapi_ver, houdini_ver, replacement ) \
110  HAPI_EXTERN_C \
111  HAPI_DEPRECATED_REPLACE( hapi_ver, houdini_ver, replacement ) \
112  HAPI_API \
113  HAPI_RETURN
114 
115 #define HAPI_DECL HAPI_EXTERN_C HAPI_API HAPI_RETURN
116 #define HAPI_DEF HAPI_EXTERN_C HAPI_RETURN
117 
118 // Static asserts
119 #ifdef __cplusplus
120 #define HAPI_STATIC_ASSERT( cond, msg ) \
121  template< bool b > \
122  struct HAPI_StaticAssert_##msg {}; \
123  template<> \
124  struct HAPI_StaticAssert_##msg< true > \
125  { \
126  typedef int static_assert_##msg; \
127  }; \
128  typedef HAPI_StaticAssert_##msg< ( cond ) >::static_assert_##msg _sa
129 #else
130  #define HAPI_STATIC_ASSERT( cond, msg ) HAPI_STATIC_ASSERT_I( cond, msg )
131  #define HAPI_STATIC_ASSERT_I( cond, msg ) \
132  typedef char static_assert_##msg[ 2 * ( cond ) - 1 ]
133 #endif // __cplusplus
134 
135 #endif // __HAPI_API_h__