1 #if ! __WXMP_Common_hpp__ 2 #define __WXMP_Common_hpp__ 1 3 4 // ================================================================================================= 5 // Copyright 2002-2007 Adobe Systems Incorporated 6 // All Rights Reserved. 7 // 8 // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms 9 // of the Adobe license agreement accompanying it. 10 // ================================================================================================= 11 12 #ifndef XMP_Inline 13 #if TXMP_EXPAND_INLINE 14 #define XMP_Inline inline 15 #else 16 #define XMP_Inline /* not inline */ 17 #endif 18 #endif 19 20 #define XMP_CTorDTorIntro(Class) template <class tStringObj> XMP_Inline Class<tStringObj> 21 #define XMP_MethodIntro(Class,ResultType) template <class tStringObj> XMP_Inline ResultType Class<tStringObj> 22 23 struct WXMP_Result { 24 XMP_StringPtr errMessage; 25 void * ptrResult; 26 double floatResult; 27 XMP_Uns64 int64Result; 28 XMP_Uns32 int32Result; WXMP_ResultWXMP_Result29 WXMP_Result() : errMessage(0) {}; 30 }; 31 32 #if __cplusplus 33 extern "C" { 34 #endif 35 36 #define PropagateException(res) \ 37 if ( res.errMessage != 0 ) throw XMP_Error ( res.int32Result, res.errMessage ); 38 39 #ifndef TraceXMPCalls 40 #define TraceXMPCalls 0 41 #endif 42 43 #if ! TraceXMPCalls 44 #define InvokeCheck(WCallProto) \ 45 WXMP_Result wResult; \ 46 WCallProto; \ 47 PropagateException ( wResult ) 48 #else 49 #define InvokeCheck(WCallProto) \ 50 WXMP_Result wResult; \ 51 fprintf ( stderr, "WXMP calling: %s\n", #WCallProto ); fflush ( stderr ); \ 52 WCallProto; \ 53 if ( wResult.errMessage == 0 ) { \ 54 fprintf ( stderr, "WXMP back, no error\n" ); fflush ( stderr ); \ 55 } else { \ 56 fprintf ( stderr, "WXMP back, error: %s\n", wResult.errMessage ); fflush ( stderr ); \ 57 } \ 58 PropagateException ( wResult ) 59 #endif 60 61 // ------------------------------------------------------------------------------------------------- 62 63 #define WrapNoCheckVoid(WCallProto) \ 64 WCallProto; 65 66 #define WrapCheckVoid(WCallProto) \ 67 InvokeCheck(WCallProto) 68 69 #define WrapCheckMetaRef(result,WCallProto) \ 70 InvokeCheck(WCallProto); \ 71 XMPMetaRef result = XMPMetaRef(wResult.ptrResult) 72 73 #define WrapCheckIterRef(result,WCallProto) \ 74 InvokeCheck(WCallProto); \ 75 XMPIteratorRef result = XMPIteratorRef(wResult.ptrResult) 76 77 #define WrapCheckDocOpsRef(result,WCallProto) \ 78 InvokeCheck(WCallProto); \ 79 XMPDocOpsRef result = XMPDocOpsRef(wResult.ptrResult) 80 81 #define WrapCheckBool(result,WCallProto) \ 82 InvokeCheck(WCallProto); \ 83 bool result = bool(wResult.int32Result) 84 85 #define WrapCheckTriState(result,WCallProto) \ 86 InvokeCheck(WCallProto); \ 87 XMP_TriState result = XMP_TriState(wResult.int32Result) 88 89 #define WrapCheckOptions(result,WCallProto) \ 90 InvokeCheck(WCallProto); \ 91 XMP_OptionBits result = XMP_OptionBits(wResult.int32Result) 92 93 #define WrapCheckStatus(result,WCallProto) \ 94 InvokeCheck(WCallProto); \ 95 XMP_Status result = XMP_Status(wResult.int32Result) 96 97 #define WrapCheckIndex(result,WCallProto) \ 98 InvokeCheck(WCallProto); \ 99 XMP_Index result = XMP_Index(wResult.int32Result) 100 101 #define WrapCheckInt32(result,WCallProto) \ 102 InvokeCheck(WCallProto); \ 103 XMP_Int32 result = wResult.int32Result 104 105 #define WrapCheckInt64(result,WCallProto) \ 106 InvokeCheck(WCallProto); \ 107 XMP_Int64 result = wResult.int64Result 108 109 #define WrapCheckFloat(result,WCallProto) \ 110 InvokeCheck(WCallProto); \ 111 double result = wResult.floatResult 112 113 #define WrapCheckFormat(result,WCallProto) \ 114 InvokeCheck(WCallProto); \ 115 XMP_FileFormat result = wResult.int32Result 116 117 // ================================================================================================= 118 119 #if __cplusplus 120 } /* extern "C" */ 121 #endif 122 123 #endif // __WXMP_Common_hpp__ 124