Skip to content

Commit 5a3bb15

Browse files
authored
Merge pull request #167 from swig-fortran/revert-typemap
Remove the curly brace typemap argument feature; see swig#1399 .
2 parents 206089b + 902b61f commit 5a3bb15

File tree

9 files changed

+15
-68
lines changed

9 files changed

+15
-68
lines changed

Examples/test-suite/common.mk

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,6 @@ CPP_TEST_CASES += \
523523
typedef_sizet \
524524
typedef_struct_cpp \
525525
typedef_typedef \
526-
typemap_args \
527526
typemap_arrays \
528527
typemap_array_qualifiers \
529528
typemap_delete \

Examples/test-suite/typemap_args.i

Lines changed: 0 additions & 32 deletions
This file was deleted.

Lib/fortran/bindc.swg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
%typemap(bindc) const CLS* = const FORTRAN_INTRINSIC_TYPE*;
4848

4949
// Set up C type
50-
%typemap(ctype, in={const CLS*}, null={SWIG_null_struct_ ## CLS()}, fragment="SWIG_null_struct"{CLS}, noblock=1) CLS {
50+
%typemap(ctype, in="const " #CLS "*", null="SWIG_null_struct_" #CLS "()", fragment="SWIG_null_struct"{CLS}, noblock=1) CLS {
5151
CLS
5252
}
5353

Lib/fortran/boost_shared_ptr.i

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@
4242
* Deferred copy of basic settings from non-SP type (i.e. Fortran will see it the same; we override the in/out/ctype below)
4343
*/
4444

45-
%typemap(ftype, in={$typemap(ftype:in, TYPE*)}, noblock=1) SWIGSP__, SWIGSP_PTRS__
45+
%typemap(ftype, in="$typemap(ftype:in, " #TYPE "*)", noblock=1) SWIGSP__, SWIGSP_PTRS__
4646
{$typemap(ftype, TYPE*)}
47-
%typemap(ftype, in={$typemap(ftype:in, const TYPE*)}, noblock=1) SWIGSP_CPTRS__
47+
%typemap(ftype, in="$typemap(ftype:in, const " #TYPE "*)", noblock=1) SWIGSP_CPTRS__
4848
{$typemap(ftype, const TYPE*)}
4949

5050
/* -------------------------------------------------------------------------

Lib/fortran/complex.i

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ struct SwigComplex_ ## CTYPE;
3232
%apply SwigComplex_ ## CTYPE ARRAY[] { CPPTYPE ARRAY[] };
3333
%apply SwigComplex_ ## CTYPE[ANY] { CPPTYPE[ANY] };
3434

35-
%typemap(ctype, in="SwigComplex_" #CTYPE "*", null="SWIG_create_complex_" # CTYPE "(0, 0)", fragment="SWIG_complex_"{CTYPE}, noblock=1) CPPTYPE {
35+
%typemap(ctype, in="SwigComplex_" #CTYPE "*", null="SWIG_create_complex_" #CTYPE "(0, 0)", fragment="SWIG_complex_"{CTYPE}, noblock=1) CPPTYPE {
3636
SwigComplex_ ## CTYPE
3737
}
3838
%typemap(in, noblock=1) CPPTYPE {

Lib/fortran/fortranarray.swg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ end subroutine}
5757
%fortran_array(CPPTYPE)
5858

5959
// Fortran proxy code: input is target 1D array
60-
%typemap(ftype, in={$typemap(imtype, VTYPE), dimension(:), target}, noblock=1) CPPTYPE {
60+
%typemap(ftype, in="$typemap(imtype, " #VTYPE "), dimension(:), target", noblock=1) CPPTYPE {
6161
$typemap(imtype, VTYPE), dimension(:), pointer
6262
}
6363

@@ -90,7 +90,7 @@ end subroutine}
9090
%define %fortran_array_handle(VTYPE, CPPTYPE...)
9191

9292
// Input arguments for pointer-by-ref are the same
93-
%typemap(ftype, in={$typemap(imtype, VTYPE), dimension(:), pointer, intent(inout)}, noblock=1) CPPTYPE& {
93+
%typemap(ftype, in="$typemap(imtype, " #VTYPE "), dimension(:), pointer, intent(inout)", noblock=1) CPPTYPE& {
9494
$typemap(imtype, VTYPE), dimension(:), pointer
9595
}
9696
%typemap(fin, match="ftype", noblock=1) CPPTYPE& {$typemap(fin, VTYPE ARRAY[])}

Lib/fortran/fundamental.swg

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -143,14 +143,14 @@ SWIGINTERN SwigArrayWrapper SwigArrayWrapper_uninitialized() {
143143
%fortran_apply_typemaps(FORTRAN_INTRINSIC_TYPE, CTYPE)
144144

145145
// Regular values are passed as pointers and returned by value
146-
%typemap(ctype, in={const CTYPE*}) CTYPE
146+
%typemap(ctype, in="const " #CTYPE "*") CTYPE
147147
%{CTYPE%}
148-
%typemap(imtype, in={FTYPE(FKIND), intent(in)}) CTYPE
148+
%typemap(imtype, in=#FTYPE "(" #FKIND "), intent(in)") CTYPE
149149
%{FTYPE(FKIND)%}
150-
%typemap(ftype, in={FTYPE(FKIND), intent(in)}) CTYPE
150+
%typemap(ftype, in=#FTYPE "(" #FKIND "), intent(in)") CTYPE
151151
%{FTYPE(FKIND)%}
152-
%typemap(bindc, in={FTYPE(FKIND), intent(in), value}, kind={FKIND},
153-
fortranconst={FTYPE(FKIND)}) CTYPE
152+
%typemap(bindc, in=#FTYPE "(" #FKIND "), intent(in), value", kind=#FKIND,
153+
fortranconst=#FTYPE "(" #FKIND ")") CTYPE
154154
%{FTYPE(FKIND)%}
155155
%typemap(in) CTYPE = FORTRAN_INTRINSIC_TYPE;
156156
%typemap(out) CTYPE = FORTRAN_INTRINSIC_TYPE;

Lib/fortran/typemaps.i

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ $2 = $input->size;
2626
%apply (SWIGTYPE *DATA, size_t SIZE) { (const SWIGTYPE *DATA, size_t SIZE) };
2727

2828
/* Add 'intent(in)' for const arrays */
29-
%typemap(ftype, in={$typemap(imtype, $*1_ltype), dimension(:), intent(in), target}, noblock=1) (const SWIGTYPE *DATA, size_t SIZE) {
29+
%typemap(ftype, in="$typemap(imtype, $*1_ltype), dimension(:), intent(in), target", noblock=1) (const SWIGTYPE *DATA, size_t SIZE) {
3030
$typemap(imtype, $*1_ltype), dimension(:), pointer
3131
}
3232

Source/CParse/parser.y

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1693,7 +1693,7 @@ static String *add_qualifier_to_declarator(SwigType *type, SwigType *qualifier)
16931693
%type <decl> abstract_declarator direct_abstract_declarator ctor_end;
16941694
%type <tmap> typemap_type;
16951695
%type <str> idcolon idcolontail idcolonnt idcolontailnt idtemplate idtemplatetemplate stringbrace stringbracesemi;
1696-
%type <str> string stringnum stringnumbrace wstring;
1696+
%type <str> string stringnum wstring;
16971697
%type <tparms> template_parms;
16981698
%type <dtype> cpp_end cpp_vend;
16991699
%type <intvalue> rename_namewarn;
@@ -7327,12 +7327,12 @@ options : LPAREN kwargs RPAREN {
73277327

73287328

73297329
/* Keyword arguments */
7330-
kwargs : idstring EQUAL stringnumbrace {
7330+
kwargs : idstring EQUAL stringnum {
73317331
$$ = NewHash();
73327332
Setattr($$,"name",$1);
73337333
Setattr($$,"value",$3);
73347334
}
7335-
| idstring EQUAL stringnumbrace COMMA kwargs {
7335+
| idstring EQUAL stringnum COMMA kwargs {
73367336
$$ = NewHash();
73377337
Setattr($$,"name",$1);
73387338
Setattr($$,"value",$3);
@@ -7366,26 +7366,6 @@ stringnum : string {
73667366
}
73677367
;
73687368

7369-
stringnumbrace : string {
7370-
$$ = $1;
7371-
}
7372-
| LBRACE {
7373-
/* Assign exact typemap contents */
7374-
String *code;
7375-
skip_balanced('{','}');
7376-
Delitem(scanner_ccode,0);
7377-
Delitem(scanner_ccode,DOH_END);
7378-
code = Copy(scanner_ccode);
7379-
$$ = code;
7380-
}
7381-
| HBLOCK {
7382-
$$ = $1;
7383-
}
7384-
| exprnum {
7385-
$$ = Char($1.val);
7386-
}
7387-
;
7388-
73897369
empty : ;
73907370

73917371
%%

0 commit comments

Comments
 (0)