-
Notifications
You must be signed in to change notification settings - Fork 1
/
pgopogl.h
60 lines (53 loc) · 1.8 KB
/
pgopogl.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Library General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at your
* option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
* License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307 USA.
*
*/
#ifndef _PGOPOGL_H_
#define _PGOPOGL_H_
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#include "ppport.h"
/*
* miscellaneous
*/
/* never use this function directly. use PGOPOGL_CALL_BOOT. */
void _pgopogl_call_XS (pTHX_ void (*subaddr) (pTHX_ CV *), CV * cv, SV ** mark);
/*
* call the boot code of a module by symbol rather than by name.
*
* in a perl extension which uses several xs files but only one pm, you
* need to bootstrap the other xs files in order to get their functions
* exported to perl. if the file has MODULE = Foo::Bar, the boot symbol
* would be boot_Foo__Bar.
*/
#define PGOPOGL_CALL_BOOT(name) \
{ \
extern XS(name); \
_pgopogl_call_XS (aTHX_ name, cv, mark); \
}
#define PackCallbackST(av,first) \
if (SvROK(ST(first)) && (SvTYPE(SvRV(ST(first))) == SVt_PVAV)){ \
int i; \
AV * x = (AV*)SvRV(ST(first)); \
for(i=0;i<=av_len(x);i++) { \
av_push(av, newSVsv(*av_fetch(x, i, 0))); \
} \
} else { \
int i; \
for(i=first;i<items;i++) \
av_push(av, newSVsv(ST(i))); \
}
#endif