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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
/* Export the SWIG initialization function */
%header %{
#ifdef __cplusplus
extern "C"
#endif
#ifndef PERL_OBJECT
#ifndef MULTIPLICITY
SWIGEXPORT void SWIG_init (CV* cv);
#else
SWIGEXPORT void SWIG_init (pTHXo_ CV* cv);
#endif
#else
SWIGEXPORT void SWIG_init (CV *cv, CPerlObj *);
#endif
%}
/* Module initialization function */
%insert(init) "swiginit.swg"
%init %{
#if defined(__cplusplus) && ! defined(XSPROTO)
extern "C"
#endif
XS(SWIG_init) {
dXSARGS;
int i;
(void)items;
SWIG_InitializeModule(0);
/* Install commands */
for (i = 0; swig_commands[i].name; i++) {
/* Casts only needed for Perl < 5.10. */
#ifdef __cplusplus
newXS(const_cast<char*>(swig_commands[i].name), swig_commands[i].wrapper, const_cast<char*>(__FILE__));
#else
newXS((char*)swig_commands[i].name, swig_commands[i].wrapper, (char*)__FILE__);
#endif
}
/* Install variables */
for (i = 0; swig_variables[i].name; i++) {
SV *sv;
sv = get_sv(swig_variables[i].name, TRUE | 0x2 | GV_ADDMULTI);
if (swig_variables[i].type) {
SWIG_MakePtr(sv,(void *)1, *swig_variables[i].type,0);
} else {
sv_setiv(sv,(IV) 0);
}
swig_create_magic(sv, swig_variables[i].name, swig_variables[i].set, swig_variables[i].get);
}
/* Install constant */
for (i = 0; swig_constants[i].type; i++) {
SV *sv;
sv = get_sv(swig_constants[i].name, TRUE | 0x2 | GV_ADDMULTI);
switch(swig_constants[i].type) {
case SWIG_INT:
sv_setiv(sv, (IV) swig_constants[i].lvalue);
break;
case SWIG_FLOAT:
sv_setnv(sv, (double) swig_constants[i].dvalue);
break;
case SWIG_STRING:
sv_setpv(sv, (const char *) swig_constants[i].pvalue);
break;
case SWIG_POINTER:
SWIG_MakePtr(sv, swig_constants[i].pvalue, *(swig_constants[i].ptype),0);
break;
case SWIG_BINARY:
SWIG_MakePackedObj(sv, swig_constants[i].pvalue, swig_constants[i].lvalue, *(swig_constants[i].ptype));
break;
default:
break;
}
SvREADONLY_on(sv);
}
%}
|