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

fix compile errors

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