Skip to content
Browse files

removed debug messages, code cleanup

  • Loading branch information...
1 parent 126f3c8 commit 2536d28dd1fe7e79145ce0907804677e9d30828d Tobias Leich committed Jan 28, 2011
Showing with 30 additions and 45 deletions.
  1. +25 −39 src/helper.h
  2. +5 −6 typemap
View
64 src/helper.h
@@ -11,24 +11,24 @@ void *bag2obj( SV *bag )
{
void *obj = NULL;
- if( sv_isobject(bag) && (SvTYPE(SvRV(bag)) == SVt_PVMG) ) {
+ if( sv_isobject(bag) && (SvTYPE(SvRV(bag)) == SVt_PVMG) )
+ {
void **pointers = (void **)(SvIV((SV *)SvRV( bag )));
- obj = (void *)(pointers[0]);
+ obj = (void *)(pointers[0]);
}
return obj;
}
SV *obj2bag( int size_ptr, void *obj, char *CLASS )
{
- SV * objref = newSV( size_ptr );
- void** pointers = malloc(3 * sizeof(void*));
- pointers[0] = (void*)obj;
- pointers[1] = (void*)PERL_GET_CONTEXT;
+ SV * objref = newSV( size_ptr );
+ void** pointers = malloc(3 * sizeof(void*));
+ pointers[0] = (void*)obj;
+ pointers[1] = (void*)PERL_GET_CONTEXT;
Uint32 *threadid = (Uint32 *)malloc(sizeof(Uint32));
- *threadid = SDL_ThreadID();
- pointers[2] = (void*)threadid;
- warn("helper.h/obj2bag: %d", *threadid);
+ *threadid = SDL_ThreadID();
+ pointers[2] = (void*)threadid;
sv_setref_pv( objref, CLASS, (void *)pointers);
return objref;
}
@@ -39,15 +39,13 @@ SV *cpy2bag( void *object, int p_size, int s_size, char *package )
void *copy = safemalloc( s_size );
memcpy( copy, object, s_size );
- void** pointers = malloc(3 * sizeof(void*));
- pointers[0] = (void*)copy;
- pointers[1] = (void*)PERL_GET_CONTEXT;
+ void** pointers = malloc(3 * sizeof(void*));
+ pointers[0] = (void*)copy;
+ pointers[1] = (void*)PERL_GET_CONTEXT;
Uint32 *threadid = (Uint32 *)malloc(sizeof(Uint32));
- *threadid = SDL_ThreadID();
- pointers[2] = (void*)threadid;
- warn("helper.h/cpy2bag: %d", *threadid);
-
- SV* a = newSVsv(sv_setref_pv(ref, package, (void *)pointers));
+ *threadid = SDL_ThreadID();
+ pointers[2] = (void*)threadid;
+ SV* a = newSVsv(sv_setref_pv(ref, package, (void *)pointers));
return a;
}
@@ -56,20 +54,16 @@ void objDESTROY(SV *bag, void (* callback)(void *object))
if( sv_isobject(bag) && (SvTYPE(SvRV(bag)) == SVt_PVMG) )
{
- warn("Called objD on %p", bag);
- void** pointers = (void**)(SvIV((SV*)SvRV( bag )));
- void* object = pointers[0];
+ void** pointers = (void**)(SvIV((SV*)SvRV( bag )));
+ void* object = pointers[0];
Uint32 *threadid = (Uint32*)(pointers[2]);
- warn("helper.h/objDESTROY: %d <> %d -> %p", *threadid, SDL_ThreadID(), object);
-
- if (PERL_GET_CONTEXT == pointers[1])
+ if(PERL_GET_CONTEXT == pointers[1]
+ && *threadid == SDL_ThreadID())
{
pointers[0] = NULL;
- if(object) {
+ if(object)
callback(object);
- warn("helper.h/objDESTROY: DESTOYED!");
- }
safefree(pointers);
}
}
@@ -81,22 +75,14 @@ SV *_sv_ref( void *object, int p_size, int s_size, char *package )
void *copy = safemalloc( s_size );
memcpy( copy, object, s_size );
- void** pointers = malloc(3 * sizeof(void*));
- pointers[0] = (void*)copy;
- pointers[1] = (void*)perl;
+ void** pointers = malloc(3 * sizeof(void*));
+ pointers[0] = (void*)copy;
+ pointers[1] = (void*)perl;
Uint32 *threadid = (Uint32 *)malloc(sizeof(Uint32));
- *threadid = SDL_ThreadID();
- pointers[2] = (void*)threadid;
- warn("helper.h/_sv_ref: %d", *threadid);
+ *threadid = SDL_ThreadID();
+ pointers[2] = (void*)threadid;
return newSVsv(sv_setref_pv(ref, package, (void *)pointers));
}
-void print_pointer( const char* message, void* pointer )
-{
-
- warn( "%s %p", message, pointer);
-
-}
-
#endif
View
11 typemap
@@ -111,13 +111,12 @@ O_OBJECT_NPGC
O_OBJECT
if ($var) {
- void** pointers = malloc(3 * sizeof(void*));
- pointers[0] = (void*)$var;
- pointers[1] = (void*)PERL_GET_CONTEXT;
+ void** pointers = malloc(3 * sizeof(void*));
+ pointers[0] = (void*)$var;
+ pointers[1] = (void*)PERL_GET_CONTEXT;
Uint32 *threadid = (Uint32 *)malloc(sizeof(Uint32));
- *threadid = SDL_ThreadID();
- pointers[2] = (void*)threadid;
- warn("typemap/OUTPUT: %d -> %p", *threadid, pointers[0]);
+ *threadid = SDL_ThreadID();
+ pointers[2] = (void*)threadid;
sv_setref_pv( $arg, CLASS, (void*)pointers );
} else {
XSRETURN_UNDEF;

0 comments on commit 2536d28

Please sign in to comment.
Something went wrong with that request. Please try again.