提交 058c8912 编写于 作者: weixin_48148422's avatar weixin_48148422

fix compile errors

上级 c24f7ea7
......@@ -18,6 +18,7 @@
#include <setjmp.h>
#include <stdint.h>
#include <stdbool.h>
#include <assert.h>
#ifdef __cplusplus
......@@ -58,7 +59,7 @@ void cleanupPush_int_int ( bool failOnly, void* func, int arg );
void cleanupPush_void ( bool failOnly, void* func );
int32_t cleanupGetActionCount();
void cleanupExecute( bool failed, int32_t toIndex );
void cleanupExecute( int32_t anchor, bool failed );
#define CLEANUP_PUSH_VOID_PTR_PTR( failOnly, func, arg1, arg2 ) cleanupPush_void_ptr_ptr( (failOnly), (void*)(func), (void*)(arg1), (void*)(arg2) )
#define CLEANUP_PUSH_VOID_PTR_BOOL( failOnly, func, arg1, arg2 ) cleanupPush_void_ptr_bool( (failOnly), (void*)(func), (void*)(arg1), (bool)(arg2) )
......
......@@ -22,7 +22,7 @@ void exceptionThrow( int code ) {
static void cleanupWrapper_void_ptr_ptr( SCleanupAction* ca ) {
void (*func)( void*, void* ) = ac->func;
void (*func)( void*, void* ) = ca->func;
func( ca->arg1.Ptr, ca->arg2.Ptr );
}
......@@ -46,7 +46,8 @@ static void cleanupWrapper_void_void( SCleanupAction* ca ) {
func();
}
static void (*wrappers)(SCleanupAction*)[] = {
typedef void (*wrapper)(SCleanupAction*);
static wrapper wrappers[] = {
cleanupWrapper_void_ptr_ptr,
cleanupWrapper_void_ptr_bool,
cleanupWrapper_void_ptr,
......@@ -58,57 +59,57 @@ static void (*wrappers)(SCleanupAction*)[] = {
void cleanupPush_void_ptr_ptr( bool failOnly, void* func, void* arg1, void* arg2 ) {
assert( expList->numCleanupAction < expList->maxCleanupAction );
SCleanupAction *ac = expList->cleanupActions + expList->numCleanupAction++;
ac->wrapper = 0;
ac->failOnly = failOnly;
ac->func = func;
ac->arg1.Ptr = arg1;
ac->arg2.Ptr = arg2;
SCleanupAction *ca = expList->cleanupActions + expList->numCleanupAction++;
ca->wrapper = 0;
ca->failOnly = failOnly;
ca->func = func;
ca->arg1.Ptr = arg1;
ca->arg2.Ptr = arg2;
}
void cleanupPush_void_ptr_bool( bool failOnly, void* func, void* arg1, bool arg2 ) {
assert( expList->numCleanupAction < expList->maxCleanupAction );
SCleanupAction *ac = expList->cleanupActions + expList->numCleanupAction++;
ac->wrapper = 1;
ac->failOnly = failOnly;
ac->func = func;
ac->arg1.Ptr = arg1;
ac->arg2.Bool = arg2;
SCleanupAction *ca = expList->cleanupActions + expList->numCleanupAction++;
ca->wrapper = 1;
ca->failOnly = failOnly;
ca->func = func;
ca->arg1.Ptr = arg1;
ca->arg2.Bool = arg2;
}
void cleanupPush_void_ptr( bool failOnly, void* func, void* arg ) {
assert( expList->numCleanupAction < expList->maxCleanupAction );
SCleanupAction *ac = expList->cleanupActions + expList->numCleanupAction++;
ac->wrapper = 2;
ac->failOnly = failOnly;
ac->func = func;
ac->arg1.Ptr = arg1;
SCleanupAction *ca = expList->cleanupActions + expList->numCleanupAction++;
ca->wrapper = 2;
ca->failOnly = failOnly;
ca->func = func;
ca->arg1.Ptr = arg;
}
void cleanupPush_int_int( bool failOnly, void* func, int arg ) {
assert( expList->numCleanupAction < expList->maxCleanupAction );
SCleanupAction *ac = expList->cleanupActions + expList->numCleanupAction++;
ac->wrapper = 3;
ac->failOnly = failOnly;
ac->func = func;
ac->arg1.Int = arg;
SCleanupAction *ca = expList->cleanupActions + expList->numCleanupAction++;
ca->wrapper = 3;
ca->failOnly = failOnly;
ca->func = func;
ca->arg1.Int = arg;
}
void cleanupPush_void( bool failOnly, void* func ) {
assert( expList->numCleanupAction < expList->maxCleanupAction );
SCleanupAction *ac = expList->cleanupActions + expList->numCleanupAction++;
ac->wrapper = 4;
ac->failOnly = failOnly;
ac->func = func;
SCleanupAction *ca = expList->cleanupActions + expList->numCleanupAction++;
ca->wrapper = 4;
ca->failOnly = failOnly;
ca->func = func;
}
int32 cleanupGetActionCount() {
int32_t cleanupGetActionCount() {
return expList->numCleanupAction;
}
......@@ -116,8 +117,8 @@ int32 cleanupGetActionCount() {
void cleanupExecute( int32_t anchor, bool failed ) {
while( expList->numCleanupAction > anchor ) {
--expList->numCleanupAction;
SCleanupAction *ac = expList->cleanupActions + expList->numCleanupAction;
if( failed || !(ac->failOnly) )
ac->wrapper( ac );
SCleanupAction *ca = expList->cleanupActions + expList->numCleanupAction;
if( failed || !(ca->failOnly) )
wrappers[ca->wrapper]( ca );
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册