Cleanup SWIG_VERSION definition
Add Swig_obligatory_macros which must be called by each target language to define SWIG_VERSION correctly in the generated code, as well as the language specific macro SWIGXXX where XXX is the target language name. Drop the #ifdef SWIGXXX that was previously generated - I can't see the point of this and if users are defining this macro somehow, then users will need to change this Closes #1050
This commit is contained in:
parent
e123c2afe8
commit
46f7501d94
31 changed files with 68 additions and 76 deletions
|
|
@ -62,6 +62,44 @@ const char *Swig_package_version(void) {
|
|||
return fake_version ? fake_version : PACKAGE_VERSION;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_package_version_hex()
|
||||
*
|
||||
* Return the package version in hex format "0xAABBCC" such as "0x040200" for 4.2.0
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
String *Swig_package_version_hex(void) {
|
||||
String *package_version = NewString(Swig_package_version());
|
||||
char *token = strtok(Char(package_version), ".");
|
||||
String *vers = NewString("SWIG_VERSION 0x");
|
||||
int count = 0;
|
||||
while (token) {
|
||||
int len = (int)strlen(token);
|
||||
assert(len == 1 || len == 2);
|
||||
Printf(vers, "%s%s", (len == 1) ? "0" : "", token);
|
||||
token = strtok(NULL, ".");
|
||||
count++;
|
||||
}
|
||||
Delete(package_version);
|
||||
assert(count == 3); // Check version format is correct
|
||||
return vers;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_obligatory_macros()
|
||||
*
|
||||
* Generates the SWIG_VERSION and SWIGXXX macros where XXX is the target language
|
||||
* name (must be provided uppercase).
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void Swig_obligatory_macros(String *f_runtime, const char *language) {
|
||||
String *version_hex = Swig_package_version_hex();
|
||||
Printf(f_runtime, "\n\n");
|
||||
Printf(f_runtime, "#define %s\n", version_hex);
|
||||
Printf(f_runtime, "#define SWIG%s\n", language);
|
||||
Delete(version_hex);
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_banner()
|
||||
*
|
||||
|
|
|
|||
|
|
@ -308,6 +308,8 @@ extern int ParmList_is_compactdefargs(ParmList *p);
|
|||
extern char *Swig_copy_string(const char *c);
|
||||
extern void Swig_set_fakeversion(const char *version);
|
||||
extern const char *Swig_package_version(void);
|
||||
extern String *Swig_package_version_hex(void);
|
||||
extern void Swig_obligatory_macros(String *f_runtime, const char *language);
|
||||
extern void Swig_banner(File *f);
|
||||
extern void Swig_banner_target_lang(File *f, const_String_or_char_ptr commentchar);
|
||||
extern String *Swig_strip_c_comments(const String *s);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue