PageRenderTime 9ms CodeModel.GetById 1ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/src/Core/objects/Event.xs

http://github.com/PerlGameDev/SDL
Unknown | 987 lines | 810 code | 177 blank | 0 comment | 0 complexity | ce3da913fb2e0ba03263a9b17fddafda MD5 | raw file
  1#include "EXTERN.h"
  2#include "perl.h"
  3#include "XSUB.h"
  4#include "ppport.h"
  5
  6#ifndef aTHX_
  7#define aTHX_
  8#endif
  9
 10#include <SDL.h>
 11
 12SV* new_data( SV* thing )
 13{
 14 if (  SvROK( thing ) ) 
 15    return  newRV_inc(SvRV(thing ) );
 16 else
 17    return  SvREFCNT_inc(thing); 
 18
 19}
 20
 21MODULE = SDL::Event 	PACKAGE = SDL::Event    PREFIX = event_
 22
 23=for documentation
 24
 25SDL_Event -- General event structure
 26
 27 typedef union{
 28  Uint8 type;
 29  SDL_ActiveEvent active;
 30  SDL_KeyboardEvent key;
 31  SDL_MouseMotionEvent motion;
 32  SDL_MouseButtonEvent button;
 33  SDL_JoyAxisEvent jaxis;
 34  SDL_JoyBallEvent jball;
 35  SDL_JoyHatEvent jhat;
 36  SDL_JoyButtonEvent jbutton;
 37  SDL_ResizeEvent resize;
 38  SDL_ExposeEvent expose;
 39  SDL_QuitEvent quit;
 40  SDL_UserEvent user;
 41  SDL_SysWMEvent syswm;
 42 } SDL_Event;
 43
 44
 45=cut
 46
 47SDL_Event *
 48event_new (CLASS)
 49	char *CLASS
 50	CODE:
 51		RETVAL = (SDL_Event *) safemalloc(sizeof (SDL_Event));
 52		/*set userdata to NULL for now  */
 53		(RETVAL->user).data1 =(void *)NULL;
 54		(RETVAL->user).data2 =(void *)NULL;
 55
 56	OUTPUT:
 57		RETVAL
 58
 59Uint8
 60event_type ( event, ... )
 61	SDL_Event *event
 62	CODE:
 63		if( items > 1 )
 64		{
 65			event->type = SvUV( ST(1) );
 66		}
 67
 68		RETVAL = event->type;
 69	OUTPUT:
 70		RETVAL
 71
 72SDL_ActiveEvent *
 73event_active ( event, ... )
 74	SDL_Event *event
 75	PREINIT:
 76		char *CLASS = "SDL::ActiveEvent";
 77	CODE:
 78		RETVAL = &(event->active);
 79	OUTPUT:
 80		RETVAL
 81
 82Uint8
 83event_active_type ( event, ... )
 84	SDL_Event *event
 85	CODE: 
 86		SDL_ActiveEvent * a = &(event->active);
 87
 88		if( items > 1 )
 89		{
 90			a->type = SvUV( ST(1) );
 91		}
 92
 93		RETVAL = a->type;
 94	OUTPUT:
 95		RETVAL
 96
 97
 98Uint8
 99event_active_gain ( event, ... )
100	SDL_Event *event
101	CODE: 
102		SDL_ActiveEvent * a = &(event->active);
103	
104		if( items > 1 )
105		{
106			a->gain = SvUV( ST(1) );
107		}
108
109		RETVAL = a->gain;
110	OUTPUT:
111		RETVAL
112
113Uint8
114event_active_state ( event, ... )
115	SDL_Event *event
116	CODE: 
117		SDL_ActiveEvent * a = &(event->active);
118
119		if( items > 1 )
120		{
121			a->state = SvUV( ST(1) );
122		}
123
124		RETVAL = a->state;
125	OUTPUT:
126		RETVAL
127
128
129SDL_KeyboardEvent *
130event_key ( event, ... )
131	SDL_Event *event
132	PREINIT:
133		char *CLASS = "SDL::KeyboardEvent";
134	CODE:
135		RETVAL = &(event->key);
136	OUTPUT:
137		RETVAL
138
139Uint8
140event_key_type ( event, ... )
141	SDL_Event *event
142	CODE: 
143		SDL_KeyboardEvent * a = &(event->key);
144
145		if( items > 1 )
146		{
147			a->type = SvUV( ST(1) );
148		}
149
150		RETVAL = a->type;
151	OUTPUT:
152		RETVAL
153
154Uint8
155event_key_state ( event, ... )
156	SDL_Event *event
157	CODE: 
158		SDL_KeyboardEvent * a = &(event->key);
159
160		if( items > 1 )
161		{
162			a->state = SvUV( ST(1) );
163		}
164
165		RETVAL = a->state;
166	OUTPUT:
167		RETVAL
168
169SDL_keysym *
170event_key_keysym ( event, ... )
171	SDL_Event *event
172	PREINIT:
173		char* CLASS = "SDL::keysym";
174	CODE: 
175		SDL_KeyboardEvent * a = &(event->key);
176
177		if( items > 1 )
178		{
179			SDL_keysym * ksp = (SDL_keysym * )SvPV( ST(1), PL_na) ;
180			a->keysym = *ksp;
181		}
182
183		RETVAL = &(a->keysym);
184	OUTPUT:
185		RETVAL
186
187Uint8
188event_key_scancode ( event, ... )
189	SDL_Event *event
190	CODE: 
191		SDL_KeyboardEvent * a = &(event->key);
192		SDL_keysym * b        = &(a->keysym);
193		
194		if( items > 1 )
195		{
196			b->scancode = SvUV( ST(1) );
197		}
198
199		RETVAL = b->scancode;
200	OUTPUT:
201		RETVAL
202
203Uint16
204event_key_sym ( event, ... )
205	SDL_Event *event
206	CODE: 
207		SDL_KeyboardEvent * a = &(event->key);
208		SDL_keysym * b        = &(a->keysym);
209		
210		if( items > 1 )
211		{
212			b->sym = SvUV( ST(1) );
213		}
214
215		RETVAL = b->sym;
216	OUTPUT:
217		RETVAL
218
219Uint16
220event_key_mod ( event, ... )
221	SDL_Event *event
222	CODE: 
223		SDL_KeyboardEvent * a = &(event->key);
224		SDL_keysym * b        = &(a->keysym);
225		
226		if( items > 1 )
227		{
228			b->mod = SvUV( ST(1) );
229		}
230
231		RETVAL = b->mod;
232	OUTPUT:
233		RETVAL
234
235Uint16
236event_key_unicode ( event, ... )
237	SDL_Event *event
238	CODE: 
239		SDL_KeyboardEvent * a = &(event->key);
240		SDL_keysym * b        = &(a->keysym);
241		
242		if( items > 1 )
243		{
244			b->unicode = SvUV( ST(1) );
245		}
246
247		RETVAL = b->unicode;
248	OUTPUT:
249		RETVAL
250
251SDL_MouseMotionEvent *
252event_motion ( event, ... )
253	SDL_Event *event
254	PREINIT:
255		char *CLASS = "SDL::MouseMotionEvent";
256	CODE:
257		RETVAL = &(event->motion);
258	OUTPUT:
259		RETVAL
260
261Uint8
262event_motion_type ( event, ... )
263	SDL_Event *event
264	CODE: 
265		SDL_MouseMotionEvent * a = &(event->motion);
266
267		if( items > 1 )
268		{
269			a->type = SvUV( ST(1) );
270		}
271
272		RETVAL = a->type;
273	OUTPUT:
274		RETVAL
275
276Uint8
277event_motion_state ( event, ... )
278	SDL_Event *event
279	CODE: 
280		SDL_MouseMotionEvent * a = &(event->motion);
281
282		if( items > 1 )
283		{
284			a->state = SvUV( ST(1) );
285		}
286
287		RETVAL = a->state;
288	OUTPUT:
289		RETVAL
290
291Uint16
292event_motion_x ( event, ... )
293	SDL_Event *event
294	CODE: 
295		SDL_MouseMotionEvent * a = &(event->motion);
296
297		if( items > 1 )
298		{
299			a->x = SvUV( ST(1) );
300		}
301
302		RETVAL = a->x;
303	OUTPUT:
304		RETVAL
305
306Uint16
307event_motion_y ( event, ... )
308	SDL_Event *event
309	CODE: 
310		SDL_MouseMotionEvent * a = &(event->motion);
311
312		if( items > 1 )
313		{
314			a->y = SvUV( ST(1) );
315		}
316
317		RETVAL = a->y;
318	OUTPUT:
319		RETVAL
320
321Sint16
322event_motion_xrel ( event, ... )
323	SDL_Event *event
324	CODE: 
325		SDL_MouseMotionEvent * a = &(event->motion);
326
327		if( items > 1 )
328		{
329			a->xrel = SvIV( ST(1) );
330		}
331
332		RETVAL = a->xrel;
333	OUTPUT:
334		RETVAL
335
336
337Sint16
338event_motion_yrel ( event, ... )
339	SDL_Event *event
340	CODE: 
341		SDL_MouseMotionEvent * a = &(event->motion);
342
343		if( items > 1 )
344		{
345			a->yrel = SvIV( ST(1) );
346		}
347
348		RETVAL = a->yrel;
349	OUTPUT:
350		RETVAL
351
352SDL_MouseButtonEvent *
353event_button ( event, ... )
354	SDL_Event *event
355	PREINIT:
356		char *CLASS = "SDL::MouseButtonEvent";
357	CODE:
358		RETVAL = &(event->button);
359	OUTPUT:
360		RETVAL
361
362Uint8
363event_button_type ( event, ... )
364	SDL_Event *event
365	CODE: 
366		SDL_MouseButtonEvent * a = &(event->button);
367
368		if( items > 1 )
369		{
370			a->type = SvUV( ST(1) );
371		}
372	
373		RETVAL = a->type;
374	OUTPUT:
375		RETVAL
376
377Uint8
378event_button_which ( event, ... )
379	SDL_Event *event
380	CODE: 
381		SDL_MouseButtonEvent * a = &(event->button);
382
383		if( items > 1 )
384		{
385			a->which = SvUV( ST(1) );
386		}
387
388		RETVAL = a->which;
389	OUTPUT:
390		RETVAL
391
392Uint8
393event_button_button ( event, ... )
394	SDL_Event *event
395	CODE:
396		SDL_MouseButtonEvent * a = &(event->button);
397
398 		if( items > 1 )
399		{
400			a->button = SvUV( ST(1) );
401		}
402
403		RETVAL = a->button;
404	OUTPUT:
405		RETVAL
406
407Uint8
408event_button_state ( event, ... )
409	SDL_Event *event
410	CODE: 
411		SDL_MouseButtonEvent * a = &(event->button);
412
413		if( items > 1 )
414		{
415			a->state = SvUV( ST(1) );
416		}
417
418		RETVAL = a->state;
419	OUTPUT:
420		RETVAL
421
422Uint16
423event_button_x ( event, ... )
424	SDL_Event *event
425	CODE: 
426		SDL_MouseButtonEvent * a = &(event->button);
427
428		if( items > 1 )
429		{
430			a->x = SvUV( ST(1) );
431		}
432
433		RETVAL = a->x;
434	OUTPUT:
435		RETVAL
436
437Uint16
438event_button_y ( event, ... )
439	SDL_Event *event
440	CODE: 
441		SDL_MouseButtonEvent * a = &(event->button);
442
443		if( items > 1 )
444		{
445			a->y = SvUV( ST(1) );
446		}
447
448		RETVAL = a->y;
449	OUTPUT:
450		RETVAL
451
452SDL_JoyAxisEvent *
453event_jaxis ( event, ... )
454	SDL_Event * event
455	PREINIT:
456		char *CLASS = "SDL::JoyAxisEvent";
457	CODE:
458		RETVAL = &(event->jaxis);
459	OUTPUT:
460		RETVAL
461
462Uint8
463event_jaxis_type ( event, ... )
464	SDL_Event *event
465	CODE: 
466		SDL_JoyAxisEvent * a = &(event->jaxis);
467
468		if( items > 1 )
469		{
470			a->type = SvUV( ST(1) );
471		}
472
473		RETVAL = a->type;
474	OUTPUT:
475		RETVAL
476
477Uint8
478event_jaxis_which ( event, ... )
479	SDL_Event *event
480	CODE:
481		SDL_JoyAxisEvent * a = &(event->jaxis);
482
483		if( items > 1 )
484		{
485			a->which = SvUV( ST(1) );
486		}
487
488		RETVAL = a->which;
489	OUTPUT:
490		RETVAL
491
492Uint8
493event_jaxis_axis ( event, ... )
494	SDL_Event *event
495	CODE:
496		SDL_JoyAxisEvent * a = &(event->jaxis);
497
498 		if( items > 1 )
499		{
500			a->axis = SvUV( ST(1) );
501		}
502
503		RETVAL = a->axis;
504	OUTPUT:
505		RETVAL
506
507Sint16
508event_jaxis_value ( event, ... )
509	SDL_Event *event
510	CODE:
511		SDL_JoyAxisEvent * a = &(event->jaxis);
512
513		if( items > 1 )
514		{
515			a->value = SvUV( ST(1) );
516		}
517
518		RETVAL = a->value;
519	OUTPUT:
520		RETVAL
521
522SDL_JoyBallEvent *
523event_jball ( event, ... )
524	SDL_Event * event
525	PREINIT:
526		char *CLASS = "SDL::JoyBallEvent";
527	CODE:
528		RETVAL = &(event->jball);
529	OUTPUT:
530		RETVAL
531
532Uint8
533event_jball_type ( event, ... )
534	SDL_Event *event
535	CODE: 
536		SDL_JoyBallEvent * a = &(event->jball);
537
538		if( items > 1 )
539		{
540			a->type = SvUV( ST(1) );
541		}
542		
543		RETVAL = event->type;
544	OUTPUT:
545		RETVAL
546
547Uint8
548event_jball_which ( event, ... )
549	SDL_Event *event
550	CODE: 
551		SDL_JoyBallEvent * a = &(event->jball);
552
553		if( items > 1 )
554		{
555			a->which = SvUV( ST(1) );
556		}
557		
558		RETVAL = a->which;
559	OUTPUT:
560		RETVAL
561
562Uint8
563event_jball_ball ( event, ... )
564	SDL_Event *event
565	CODE:
566		SDL_JoyBallEvent * a = &(event->jball);
567
568		if( items > 1 )
569		{
570			a->ball = SvUV( ST(1) );
571		}
572		
573		RETVAL = a->ball;
574	OUTPUT:
575		RETVAL
576
577Sint16
578event_jball_xrel ( event, ... )
579	SDL_Event *event
580	CODE: 
581		SDL_JoyBallEvent * a = &(event->jball);
582
583		if( items > 1 )
584		{
585			a->xrel = SvIV( ST(1) );
586		}
587
588		RETVAL = a->xrel;
589	OUTPUT:
590		RETVAL
591
592Sint16
593event_jball_yrel ( event, ... )
594	SDL_Event *event
595	CODE: 
596		SDL_JoyBallEvent * a = &(event->jball);
597
598		if( items > 1 )
599		{
600			a->yrel = SvIV( ST(1) );
601		}
602
603		RETVAL = a->yrel;
604	OUTPUT:
605		RETVAL
606
607SDL_JoyHatEvent *
608event_jhat ( event, ... )
609	SDL_Event *event
610	PREINIT:
611		char *CLASS = "SDL::JoyHatEvent";
612	CODE:
613		RETVAL = NULL;
614		if ( &event != NULL ) 
615		RETVAL = &(event->jhat);
616	OUTPUT:
617		RETVAL
618
619Uint8
620event_jhat_type ( event, ... )
621	SDL_Event *event
622	CODE: 
623		SDL_JoyHatEvent * a = &(event->jhat);
624
625		if( items > 1 )
626		{
627			a->which = SvUV( ST(1) );
628		}
629
630		RETVAL = a->type;
631	OUTPUT:
632		RETVAL
633
634Uint8
635event_jhat_which ( event, ... )
636	SDL_Event *event
637	CODE: 
638		SDL_JoyHatEvent * a = &(event->jhat);
639
640		if( items > 1 )
641		{
642			a->which = SvUV( ST(1) );
643		}
644
645		RETVAL = a->which;
646	OUTPUT:
647		RETVAL
648
649Uint8
650event_jhat_hat ( event, ... )
651	SDL_Event *event
652	CODE:
653		SDL_JoyHatEvent * a = &(event->jhat);
654
655		if( items > 1 )
656		{
657			a->hat = SvUV( ST(1) );
658		}
659
660		RETVAL = a->hat;
661	OUTPUT:
662		RETVAL
663
664Uint8
665event_jhat_value ( event, ... )
666	SDL_Event *event
667	CODE: 
668		SDL_JoyHatEvent * a = &(event->jhat);
669
670		if( items > 1 )
671		{
672			a->value = SvUV( ST(1) );
673		}
674
675		RETVAL = a->value;
676	OUTPUT:
677		RETVAL
678
679SDL_JoyButtonEvent *
680event_jbutton ( event, ... )
681	SDL_Event *event
682	PREINIT:
683		char *CLASS = "SDL::JoyButtonEvent";
684	CODE:
685		RETVAL = NULL;
686		if ( &event != NULL ) 
687		RETVAL = &(event->jbutton);
688	OUTPUT:
689		RETVAL
690
691Uint8
692event_jbutton_type ( event, ... )
693	SDL_Event *event
694	CODE:
695		SDL_JoyButtonEvent * a = &(event->jbutton);
696
697		if( items > 1 )
698		{
699			a->type = SvUV( ST(1) );
700		}
701
702		RETVAL = a->type;
703	OUTPUT:
704		RETVAL
705
706Uint8
707event_jbutton_which ( event, ... )
708	SDL_Event *event
709	CODE: 
710		SDL_JoyButtonEvent * a = &(event->jbutton);
711
712		if( items > 1 )
713		{
714			a->which = SvUV( ST(1) );
715		}
716
717		RETVAL = a->which;
718	OUTPUT:
719		RETVAL
720
721Uint8
722event_jbutton_button ( event, ... )
723	SDL_Event *event
724	CODE: 
725		SDL_JoyButtonEvent * a = &(event->jbutton);
726
727		if( items > 1 )
728		{
729			a->button = SvUV( ST(1) );
730		}
731
732		RETVAL = a->button;
733	OUTPUT:
734		RETVAL
735
736Uint8
737event_jbutton_state ( event, ... )
738	SDL_Event *event
739	CODE: 
740		SDL_JoyButtonEvent * a = &(event->jbutton);
741
742		if( items > 1 )
743		{
744			a->state = SvUV( ST(1) );
745		}
746
747		RETVAL = a->state;
748	OUTPUT:
749		RETVAL
750
751SDL_ResizeEvent *
752event_resize ( event, ... )
753	SDL_Event * event
754	PREINIT:
755		char *CLASS = "SDL::ResizeEvent";
756	CODE:
757		RETVAL = NULL;
758		if ( &event != NULL ) 
759		RETVAL = &(event->resize);
760	OUTPUT:
761		RETVAL
762
763Uint8
764event_resize_type ( event, ... )
765	SDL_Event *event
766	CODE: 
767		SDL_ResizeEvent * a = &(event->resize);
768
769		if( items > 1 )
770		{
771			a->type = SvUV( ST(1) );
772		}
773
774		RETVAL = a->type;
775	OUTPUT:
776		RETVAL
777
778int
779event_resize_w ( event, ... )
780	SDL_Event *event
781	CODE: 
782		SDL_ResizeEvent * a = &(event->resize);
783		if( items > 1 )
784		{
785			a->w = SvUV( ST(1) );
786		}
787
788		RETVAL = a->w;
789	OUTPUT:
790		RETVAL
791
792int
793event_resize_h ( event, ... )
794	SDL_Event *event
795	CODE: 
796		SDL_ResizeEvent * a = &(event->resize); 
797
798		if( items > 1 )
799		{
800			a->h = SvUV( ST(1) );
801		}
802
803		RETVAL = a->h;
804	OUTPUT:
805		RETVAL
806
807SDL_ExposeEvent *
808event_expose ( event, ... )
809	SDL_Event * event
810	PREINIT:
811		char *CLASS = "SDL::ExposeEvent";
812	CODE:
813		RETVAL = &(event->expose);
814	OUTPUT:
815		RETVAL
816
817Uint8
818event_expose_type ( event, ... )
819	SDL_Event *event
820	CODE: 
821		SDL_ExposeEvent * a = &(event->expose);
822
823		if( items > 1 )
824		{
825			a->type = SvUV( ST(1) );
826		}
827
828		RETVAL = a->type;
829	OUTPUT:
830		RETVAL
831
832SDL_QuitEvent *
833event_quit ( event, ... )
834	SDL_Event * event
835	PREINIT:
836		char *CLASS = "SDL::QuitEvent";
837	CODE:
838		RETVAL = &(event->quit);
839	OUTPUT:
840		RETVAL
841
842Uint8
843event_quit_type ( event, ... )
844	SDL_Event *event
845	CODE: 
846		SDL_QuitEvent * a = &(event->quit);
847
848		if( items > 1 )
849		{
850			a->type = SvUV( ST(1) );
851		}
852
853		RETVAL = a->type;
854	OUTPUT:
855		RETVAL
856
857SDL_UserEvent *
858event_user ( event, ... )
859	SDL_Event * event
860	PREINIT:
861		char *CLASS = "SDL::UserEvent";
862	CODE:
863		RETVAL = &(event->user);
864	OUTPUT:
865		RETVAL
866
867Uint8
868event_user_type ( event, ... )
869	SDL_Event *event
870	CODE: 
871		SDL_UserEvent * a = &(event->user);
872
873		if( items > 1 )
874		{
875			a->type = SvUV( ST(1) );
876		}
877
878		RETVAL = a->type;
879	OUTPUT:
880		RETVAL
881
882int
883event_user_code ( event, ... )
884	SDL_Event *event
885	CODE: 
886		SDL_UserEvent * a = &(event->user);
887
888		if( items > 1 )
889		{
890			a->code = SvUV( ST(1) );
891		}
892
893		RETVAL = (int)a->code;
894	OUTPUT:
895		RETVAL
896
897SV*
898event_user_data1 ( event, ... )
899	SDL_Event *event	
900	PPCODE: 
901		SDL_UserEvent * a = &(event->user);
902		if ( items > 1)
903			a->data1 = new_data( ST(1) ); 
904		 if (!a->data1)
905		  XSRETURN_EMPTY;
906		  ST(0) = a->data1;
907		  XSRETURN(1);
908
909SV*
910event_user_data2 ( event, ... ) 
911	SDL_Event *event	
912	PPCODE: 
913		SDL_UserEvent * a = &(event->user);
914		if ( items > 1)
915			a->data2 = new_data( ST(1) ); 
916		 if (!a->data2)
917		  XSRETURN_EMPTY;
918		  ST(0) = a->data2;
919		  XSRETURN(1);
920
921SDL_SysWMEvent *
922event_syswm ( event, ... )
923	SDL_Event * event
924	PREINIT:
925		char *CLASS = "SDL::SysWMEvent";
926	CODE:
927		RETVAL = &(event->syswm);
928	OUTPUT:
929		RETVAL
930
931Uint8
932event_syswm_type ( event, ... )
933	SDL_Event *event
934	CODE: 
935		SDL_SysWMEvent * a = &(event->syswm);
936
937		if( items > 1 )
938		{
939			a->type = SvUV( ST(1) );
940		}
941
942		RETVAL = a->type;
943	OUTPUT:
944		RETVAL
945
946SDL_SysWMmsg *
947event_syswm_msg ( event, ... )
948	SDL_Event *event
949	PREINIT:
950		char* CLASS = "SDL::SysWMmsg";
951	CODE: 
952		SDL_SysWMEvent * a = &(event->syswm);
953
954		if( items > 1 )
955		{
956			SDL_SysWMmsg * sysm = (SDL_SysWMmsg * )SvPV( ST(1), PL_na) ;
957			a->msg = sysm;
958		}
959
960		RETVAL = a->msg;
961	OUTPUT:
962		RETVAL
963
964void
965event_DESTROY(bag)
966	SV* bag
967	CODE:
968               if( sv_isobject(bag) && (SvTYPE(SvRV(bag)) == SVt_PVMG) ) {
969                   void** pointers = (void**)INT2PTR(void *, SvIV((SV *)SvRV( bag ))); 
970                   SDL_Event* self = (SDL_Event*)(pointers[0]);
971                   if (PERL_GET_CONTEXT == pointers[1]) {
972                       /*warn("Freed surface %p and pixels %p \n", surface, surface->pixels); */
973                       if(self->type == SDL_USEREVENT) {
974                           if( (self->user).data1 != NULL )
975                              SvREFCNT_dec( (self->user).data1);
976                           if( (self->user).data2 != NULL )
977                              SvREFCNT_dec( (self->user).data2);
978                       }
979                       safefree(self);
980					   safefree(pointers);
981                   }
982               } else if (bag == 0) {
983                   XSRETURN(0);
984               } else {
985                   XSRETURN_UNDEF;
986               }
987