PageRenderTime 151ms CodeModel.GetById 86ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/tags/rel-1-3-26/SWIG/Lib/perl5/perlinit.swg

#
Unknown | 76 lines | 66 code | 10 blank | 0 comment | 0 complexity | 0a7610f1dfd9b97cbc491a52ba12df0b MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
 1
 2/* Export the SWIG initialization function */
 3%header %{
 4#ifdef __cplusplus
 5extern "C"
 6#endif
 7#ifndef PERL_OBJECT
 8#ifndef MULTIPLICITY
 9SWIGEXPORT void SWIG_init (CV* cv);
10#else
11SWIGEXPORT void SWIG_init (pTHXo_ CV* cv);
12#endif
13#else
14SWIGEXPORT 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
25extern "C"
26#endif
27
28XS(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%}