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