Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | |
2 | /* Export the SWIG initialization function */ | |
3 | %header %{ | |
4 | #ifdef __cplusplus | |
5 | extern "C" | |
6 | #endif | |
7 | #ifndef PERL_OBJECT | |
8 | #ifndef MULTIPLICITY | |
9 | SWIGEXPORT void SWIG_init (CV* cv); | |
10 | #else | |
11 | SWIGEXPORT void SWIG_init (pTHXo_ CV* cv); | |
12 | #endif | |
13 | #else | |
14 | SWIGEXPORT void SWIG_init (CV *cv, CPerlObj *); | |
15 | #endif | |
16 | %} | |
17 | ||
18 | /* Module initialization function */ | |
19 | ||
20 | %insert(init) "swiginit.swg" | |
21 | ||
22 | %init %{ | |
23 | ||
24 | #ifdef __cplusplus | |
25 | extern "C" | |
26 | #endif | |
27 | ||
28 | XS(SWIG_init) { | |
29 | dXSARGS; | |
30 | int i; | |
31 | ||
32 | SWIG_InitializeModule(0); | |
33 | ||
34 | /* Install commands */ | |
35 | for (i = 0; swig_commands[i].name; i++) { | |
36 | newXS((char*) swig_commands[i].name,swig_commands[i].wrapper, (char*)__FILE__); | |
37 | } | |
38 | ||
39 | /* Install variables */ | |
40 | for (i = 0; swig_variables[i].name; i++) { | |
41 | SV *sv; | |
42 | sv = perl_get_sv((char*) swig_variables[i].name, TRUE | 0x2); | |
43 | if (swig_variables[i].type) { | |
44 | SWIG_MakePtr(sv,(void *)1, *swig_variables[i].type,0); | |
45 | } else { | |
46 | sv_setiv(sv,(IV) 0); | |
47 | } | |
48 | swig_create_magic(sv, (char *) swig_variables[i].name, swig_variables[i].set, swig_variables[i].get); | |
49 | } | |
50 | ||
51 | /* Install constant */ | |
52 | for (i = 0; swig_constants[i].type; i++) { | |
53 | SV *sv; | |
54 | sv = perl_get_sv((char*)swig_constants[i].name, TRUE | 0x2); | |
55 | switch(swig_constants[i].type) { | |
56 | case SWIG_INT: | |
57 | sv_setiv(sv, (IV) swig_constants[i].lvalue); | |
58 | break; | |
59 | case SWIG_FLOAT: | |
60 | sv_setnv(sv, (double) swig_constants[i].dvalue); | |
61 | break; | |
62 | case SWIG_STRING: | |
63 | sv_setpv(sv, (char *) swig_constants[i].pvalue); | |
64 | break; | |
65 | case SWIG_POINTER: | |
66 | SWIG_MakePtr(sv, swig_constants[i].pvalue, *(swig_constants[i].ptype),0); | |
67 | break; | |
68 | case SWIG_BINARY: | |
69 | SWIG_MakePackedObj(sv, swig_constants[i].pvalue, swig_constants[i].lvalue, *(swig_constants[i].ptype)); | |
70 | break; | |
71 | default: | |
72 | break; | |
73 | } | |
74 | SvREADONLY_on(sv); | |
75 | } | |
76 | %} |