Skip to content

Commit 5960658

Browse files
committed
Allow "wrapfunc" to have different line endings
This allows its to be reused for Fortran wrapper code generation.
1 parent 3108f9e commit 5960658

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

Source/Swig/swigwrap.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ typedef struct Wrapper {
1616
String *def;
1717
String *locals;
1818
String *code;
19+
const char *end_statement;
1920
} Wrapper;
2021

2122
extern Wrapper *NewWrapper(void);

Source/Swig/wrapfunc.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
static int Compact_mode = 0; /* set to 0 on default */
2020
static int Max_line_size = 128;
21+
const char C_end_statement[] = ";\n";
2122

2223
/* -----------------------------------------------------------------------------
2324
* NewWrapper()
@@ -32,6 +33,7 @@ Wrapper *NewWrapper(void) {
3233
w->locals = NewStringEmpty();
3334
w->code = NewStringEmpty();
3435
w->def = NewStringEmpty();
36+
w->end_statement = C_end_statement;
3537
return w;
3638
}
3739

@@ -391,6 +393,7 @@ void Wrapper_print(Wrapper *w, File *f) {
391393

392394
str = NewStringEmpty();
393395
Printf(str, "%s\n", w->def);
396+
if (Len(w->locals) > 0)
394397
Printf(str, "%s\n", w->locals);
395398
Printf(str, "%s\n", w->code);
396399
if (Compact_mode == 1)
@@ -414,7 +417,7 @@ int Wrapper_add_local(Wrapper *w, const_String_or_char_ptr name, const_String_or
414417
return -1;
415418
}
416419
Setattr(w->localh, name, decl);
417-
Printf(w->locals, "%s;\n", decl);
420+
Printf(w->locals, "%s%s", decl, w->end_statement);
418421
return 0;
419422
}
420423

@@ -482,7 +485,7 @@ char *Wrapper_new_local(Wrapper *w, const_String_or_char_ptr name, const_String_
482485
}
483486
Replace(ndecl, name, nname, DOH_REPLACE_ID);
484487
Setattr(w->localh, nname, ndecl);
485-
Printf(w->locals, "%s;\n", ndecl);
488+
Printf(w->locals, "%s%s", ndecl, w->end_statement);
486489
ret = Char(nname);
487490
Delete(nname);
488491
Delete(ndecl);

0 commit comments

Comments
 (0)