44 /*
45 * This macro invokes a function from the shared lib.
46 * it locates a function with SplashProcAddress on demand.
47 * if SplashProcAddress fails, def value is returned.
48 *
49 * it is further wrapped with INVOKEV (works with functions which return
50 * void and INVOKE (for all other functions). INVOKEV looks a bit ugly,
51 * that's due being unable to return a value of type void in C. INVOKEV
52 * works around this by using semicolon instead of return operator.
53 */
54 #define _INVOKE(name,def,ret) \
55 static void* proc = NULL; \
56 if (!proc) { proc = SplashProcAddress(#name); } \
57 if (!proc) { return def; } \
58 ret ((name##_t)proc)
59
60 #define INVOKE(name,def) _INVOKE(name,def,return)
61 #define INVOKEV(name) _INVOKE(name, ,;)
62
63 int DoSplashLoadMemory(void* pdata, int size) {
64 INVOKE(SplashLoadMemory, NULL)(pdata, size);
65 }
66
67 int DoSplashLoadFile(const char* filename) {
68 INVOKE(SplashLoadFile, NULL)(filename);
69 }
70
71 void DoSplashInit(void) {
72 INVOKEV(SplashInit)();
73 }
74
75 void DoSplashClose(void) {
76 INVOKEV(SplashClose)();
77 }
78
79 void DoSplashSetFileJarName(const char* fileName, const char* jarName) {
80 INVOKEV(SplashSetFileJarName)(fileName, jarName);
81 }
82
83 void DoSplashSetScaleFactor(float scaleFactor) {
84 INVOKEV(SplashSetScaleFactor)(scaleFactor);
85 }
86
87 char* DoSplashGetScaledImageName(const char* fileName, const char* jarName,
88 float* scaleFactor) {
|
44 /*
45 * This macro invokes a function from the shared lib.
46 * it locates a function with SplashProcAddress on demand.
47 * if SplashProcAddress fails, def value is returned.
48 *
49 * it is further wrapped with INVOKEV (works with functions which return
50 * void and INVOKE (for all other functions). INVOKEV looks a bit ugly,
51 * that's due being unable to return a value of type void in C. INVOKEV
52 * works around this by using semicolon instead of return operator.
53 */
54 #define _INVOKE(name,def,ret) \
55 static void* proc = NULL; \
56 if (!proc) { proc = SplashProcAddress(#name); } \
57 if (!proc) { return def; } \
58 ret ((name##_t)proc)
59
60 #define INVOKE(name,def) _INVOKE(name,def,return)
61 #define INVOKEV(name) _INVOKE(name, ,;)
62
63 int DoSplashLoadMemory(void* pdata, int size) {
64 INVOKE(SplashLoadMemory, 0)(pdata, size);
65 }
66
67 int DoSplashLoadFile(const char* filename) {
68 INVOKE(SplashLoadFile, 0)(filename);
69 }
70
71 void DoSplashInit(void) {
72 INVOKEV(SplashInit)();
73 }
74
75 void DoSplashClose(void) {
76 INVOKEV(SplashClose)();
77 }
78
79 void DoSplashSetFileJarName(const char* fileName, const char* jarName) {
80 INVOKEV(SplashSetFileJarName)(fileName, jarName);
81 }
82
83 void DoSplashSetScaleFactor(float scaleFactor) {
84 INVOKEV(SplashSetScaleFactor)(scaleFactor);
85 }
86
87 char* DoSplashGetScaledImageName(const char* fileName, const char* jarName,
88 float* scaleFactor) {
|