added %perlcode directive, patch from Fabrice Salvaire
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@6155 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
6e766985cc
commit
2b8acdf5a8
1 changed files with 24 additions and 0 deletions
|
|
@ -94,6 +94,7 @@ static int num_consts = 0; /* Number of constants */
|
||||||
static String *var_stubs = 0; /* Variable stubs */
|
static String *var_stubs = 0; /* Variable stubs */
|
||||||
static String *exported = 0; /* Exported symbols */
|
static String *exported = 0; /* Exported symbols */
|
||||||
static String *pragma_include = 0;
|
static String *pragma_include = 0;
|
||||||
|
static String *additional_perl_code = 0; /* Additional Perl code from %perlcode %{ ... %} */
|
||||||
static Hash *operators = 0;
|
static Hash *operators = 0;
|
||||||
static int have_operators = 0;
|
static int have_operators = 0;
|
||||||
|
|
||||||
|
|
@ -203,6 +204,7 @@ public:
|
||||||
exported = NewString("");
|
exported = NewString("");
|
||||||
magic = NewString("");
|
magic = NewString("");
|
||||||
pragma_include = NewString("");
|
pragma_include = NewString("");
|
||||||
|
additional_perl_code = NewString("");
|
||||||
|
|
||||||
command_tab = NewString("static swig_command_info swig_commands[] = {\n");
|
command_tab = NewString("static swig_command_info swig_commands[] = {\n");
|
||||||
constant_tab = NewString("static swig_constant_info swig_constants[] = {\n");
|
constant_tab = NewString("static swig_constant_info swig_constants[] = {\n");
|
||||||
|
|
@ -250,6 +252,7 @@ public:
|
||||||
}
|
}
|
||||||
Delete(filen); filen = NULL;
|
Delete(filen); filen = NULL;
|
||||||
Swig_register_filebyname("pm",f_pm);
|
Swig_register_filebyname("pm",f_pm);
|
||||||
|
Swig_register_filebyname("perl",f_pm);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
String *tmp = NewString(fullmodule);
|
String *tmp = NewString(fullmodule);
|
||||||
|
|
@ -445,6 +448,9 @@ public:
|
||||||
Printf(f_pm,"%s",var_stubs);
|
Printf(f_pm,"%s",var_stubs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Add additional Perl code at the end */
|
||||||
|
Printf(f_pm,"%s",additional_perl_code);
|
||||||
|
|
||||||
Printf(f_pm,"1;\n");
|
Printf(f_pm,"1;\n");
|
||||||
Close(f_pm);
|
Close(f_pm);
|
||||||
Delete(f_pm);
|
Delete(f_pm);
|
||||||
|
|
@ -1422,6 +1428,24 @@ public:
|
||||||
}
|
}
|
||||||
return Language::pragmaDirective(n);
|
return Language::pragmaDirective(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------
|
||||||
|
* insertDirective()
|
||||||
|
*
|
||||||
|
* Hook for %insert directive.
|
||||||
|
* ------------------------------------------------------------ */
|
||||||
|
|
||||||
|
virtual int insertDirective(Node *n) {
|
||||||
|
String *code = Getattr(n,"code");
|
||||||
|
String *section = Getattr(n,"section");
|
||||||
|
|
||||||
|
if ((!ImportMode) && (Cmp(section,"perl") == 0)) {
|
||||||
|
Printv(additional_perl_code, code, NIL);
|
||||||
|
} else {
|
||||||
|
Language::insertDirective(n);
|
||||||
|
}
|
||||||
|
return SWIG_OK;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue