Skip to content

Commit 54b2fa1

Browse files
authored
Merge pull request #139 from swig-fortran/fclassname
Remove `fenumname` and replace `fclassname` with `fortranclassname`
2 parents eaf0313 + b533424 commit 54b2fa1

File tree

6 files changed

+112
-136
lines changed

6 files changed

+112
-136
lines changed

Doc/Manual/src/Fortran.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1689,15 +1689,16 @@ Fortran compiler), `release` should be called on every proxy class instance.
16891689
SWIG's default Fortran type (the `ftype` typemap) for generic types such as
16901690
classes (`SWIGTYPE`) is:
16911691
```swig
1692-
%typemap(ftype) SWIGTYPE "type($fclassname)"
1692+
%typemap(ftype) SWIGTYPE "type($fortranclassname)"
16931693
```
1694-
The special symbol `$fclassname` is replaced by the symbolic name of the class
1695-
that matches the typemap. For example, if `std::vector<double>` is
1694+
The special symbol `$fortranclassname` is replaced by the symbolic name (i.e. the Fortran
1695+
identifier in the proxy code) of the class that matches the typemap.
1696+
For example, if `std::vector<double>` is
16961697
instantiated:
16971698
```swig
16981699
%template(Vec_Dbl) std::vector<double>;
16991700
```
1700-
then `Vec_Dbl`, the name of the derived type, will replace `$fclassname`.
1701+
then `Vec_Dbl`, the name of the derived type, will replace `$fortranclassname`.
17011702

17021703
If a class has *not* been wrapped but is encountered (e.g. in a function
17031704
argument or return value), a warning will be emitted: no Fortran

Lib/fortran/bindc.swg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
* ------------------------------------------------------------------------- */
44

55
// Declare a generic `FORTRAN_STRUCT_TYPE` as a native type.
6-
// Rather than being an intrinsic type `integer(C_INT)` it's a derived type `type($fclassname)`
7-
%fortran_intrinsic(FORTRAN_STRUCT_TYPE, type($fclassname))
6+
// Rather than being an intrinsic type `integer(C_INT)` it's a derived type `type($fortranclassname)`
7+
%fortran_intrinsic(FORTRAN_STRUCT_TYPE, type($fortranclassname))
88
// Avoid 'C99 forbids casting nonscalar type 'XY' to the same type'
99
%typemap(in) FORTRAN_STRUCT_TYPE "$1 = *$input;"
1010
%typemap(out) FORTRAN_STRUCT_TYPE "$result = $1;"

Lib/fortran/boost_shared_ptr.i

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
* SP-owned copy of the obtained value.
6363
* ------------------------------------------------------------------------- */
6464
%typemap(in, noblock=1, fragment="SWIG_check_sp_nonnull") CONST TYPE ($&1_type argp = 0) {
65-
SWIG_check_sp_nonnull($input->cptr, "$1_ltype", "$fclassname", "$decl", return $null)
65+
SWIG_check_sp_nonnull($input->cptr, "$1_ltype", "$fortranclassname", "$decl", return $null)
6666
argp = static_cast<SWIGSP__*>($input->cptr)->get();
6767
$1 = *argp;
6868
}
@@ -102,7 +102,7 @@
102102
* Original class by reference. Add null checks.
103103
* ------------------------------------------------------------------------- */
104104
%typemap(in, noblock=1, fragment="SWIG_check_sp_nonnull") CONST TYPE & {
105-
SWIG_check_sp_nonnull($input->cptr, "$1_ltype", "$fclassname", "$decl", return $null)
105+
SWIG_check_sp_nonnull($input->cptr, "$1_ltype", "$fortranclassname", "$decl", return $null)
106106
$1 = (TYPE*)static_cast<SWIGSP__*>($input->cptr)->get();
107107
}
108108

Lib/fortran/classes.swg

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -323,11 +323,11 @@ SWIGINTERN void SWIG_assign(SwigClassWrapper* self, SwigClassWrapper other) {
323323
%typemap(imtype, fragment="SwigClassWrapper_f")
324324
SWIGTYPE
325325
"type(SwigClassWrapper)"
326-
%typemap(ftype, in="type($&fclassname), intent(in)", nofortransubroutine=1) SWIGTYPE
327-
"type($&fclassname)"
326+
%typemap(ftype, in="type($&fortranclassname), intent(in)", nofortransubroutine=1) SWIGTYPE
327+
"type($&fortranclassname)"
328328

329329
%typemap(in, noblock=1, fragment="SWIG_check_nonnull") SWIGTYPE {
330-
SWIG_check_nonnull(*$input, "$1_ltype", "$&fclassname", "$decl", return $null);
330+
SWIG_check_nonnull(*$input, "$1_ltype", "$&fortranclassname", "$decl", return $null);
331331
$1 = *(($&1_ltype)($input->cptr));
332332
}
333333

@@ -352,8 +352,8 @@ SWIGINTERN void SWIG_assign(SwigClassWrapper* self, SwigClassWrapper other) {
352352
// Raw pointers act mostly like value types, but they don't have to accept the exact type (polymorphic input, non-polymorphic output). Intent is 'in' because
353353
// we're not modifying the pointer or memory status.
354354
%apply SWIGTYPE { SWIGTYPE* };
355-
%typemap(ftype, in="class($fclassname), intent(in)", nofortransubroutine=1) SWIGTYPE*
356-
"type($fclassname)"
355+
%typemap(ftype, in="class($fortranclassname), intent(in)", nofortransubroutine=1) SWIGTYPE*
356+
"type($fortranclassname)"
357357
%typemap(in, noblock=1) SWIGTYPE* {
358358
$1 = ($1_ltype)$input->cptr;
359359
}
@@ -373,7 +373,7 @@ SWIGINTERN void SWIG_assign(SwigClassWrapper* self, SwigClassWrapper other) {
373373
// Check for non-null reference inputs
374374
%apply SWIGTYPE* { SWIGTYPE& };
375375
%typemap(in, noblock=1, fragment="SWIG_check_nonnull") SWIGTYPE& {
376-
SWIG_check_nonnull(*$input, "$1_type", "$fclassname", "$decl", return $null);
376+
SWIG_check_nonnull(*$input, "$1_type", "$fortranclassname", "$decl", return $null);
377377
$1 = ($1_ltype)$input->cptr;
378378
}
379379

@@ -397,15 +397,15 @@ SWIGINTERN void SWIG_assign(SwigClassWrapper* self, SwigClassWrapper other) {
397397

398398
// Check for non-null class input "self"
399399
%typemap(in, noblock=1, fragment="SWIG_check_nonnull") SWIGTYPE *self {
400-
SWIG_check_nonnull(*$input, "$1_type", "$*fclassname", "$decl", return $null);
400+
SWIG_check_nonnull(*$input, "$1_type", "$*fortranclassname", "$decl", return $null);
401401
$1 = ($1_ltype)$input->cptr;
402402
}
403403

404404
// On assignment, copy pointer to input wrapper class
405405
%typemap(imtype, in="type(SwigClassWrapper), intent(inout)", fragment="SwigClassWrapper_f") SWIGTYPE *ASSIGNMENT_SELF
406406
"type(SwigClassWrapper)"
407-
%typemap(ftype, in="class($fclassname), intent(inout)", nofortransubroutine=1) SWIGTYPE *ASSIGNMENT_SELF
408-
"type($fclassname)"
407+
%typemap(ftype, in="class($fortranclassname), intent(inout)", nofortransubroutine=1) SWIGTYPE *ASSIGNMENT_SELF
408+
"type($fortranclassname)"
409409

410410
// Assignment operates directly on $input, not $1
411411
%typemap(in) SWIGTYPE *ASSIGNMENT_SELF "(void)sizeof($1);";
@@ -414,8 +414,8 @@ SWIGINTERN void SWIG_assign(SwigClassWrapper* self, SwigClassWrapper other) {
414414
}
415415

416416
// Prevent ambiguous overloads by requiring the RHS to be the exact type
417-
%typemap(ftype, in="type($fclassname), intent(in)", nofortransubroutine=1) SWIGTYPE &ASSIGNMENT_OTHER
418-
"type($fclassname)"
417+
%typemap(ftype, in="type($fortranclassname), intent(in)", nofortransubroutine=1) SWIGTYPE &ASSIGNMENT_OTHER
418+
"type($fortranclassname)"
419419
%typemap(in) SWIGTYPE &ASSIGNMENT_OTHER = SWIGTYPE *ASSIGNMENT_SELF;
420420

421421
%apply SWIGTYPE *ASSIGNMENT_SELF { SWIGTYPE *DESTRUCTOR_SELF };

Lib/fortran/enums.swg

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,17 @@
1111
// integer pointers)
1212
%fortran_unsigned(int, enum SWIGTYPE)
1313

14-
%typemap(ftype, in="integer($fenumname), intent(in)") enum SWIGTYPE
15-
"integer($fenumname)"
14+
%typemap(ftype, in="integer($fortranclassname), intent(in)") enum SWIGTYPE
15+
"integer($fortranclassname)"
1616
%typemap(out, noblock=1) enum SWIGTYPE {
1717
$result = (int)($1);
1818
}
1919
%typemap(out, noblock=1) const enum SWIGTYPE& {
2020
$result = (int)(*$1);
2121
}
2222

23-
%typemap(ftype, in="integer($*fenumname), intent(in)") const enum SWIGTYPE&
24-
"integer($*fenumname)"
23+
%typemap(ftype, in="integer($*fortranclassname), intent(in)") const enum SWIGTYPE&
24+
"integer($*fortranclassname)"
2525
%typemap(imtype) const enum SWIGTYPE& = enum SWIGTYPE;
2626
%typemap(fin) const enum SWIGTYPE& = enum SWIGTYPE;
2727
%typemap(fout) const enum SWIGTYPE& = enum SWIGTYPE;

0 commit comments

Comments
 (0)