Skip to content

Commit

Permalink
Compatibility changes for SWIG-Fortran (#31)
Browse files Browse the repository at this point in the history
* Replace deleted '{}' syntax in typemap attributes
* Add deleted <cctypes>
* Use global-namespace size_t (no change)
* Update wrapper code with latest version
  • Loading branch information
sethrj authored Jun 3, 2022
1 parent 82c78fc commit 0ada9ff
Show file tree
Hide file tree
Showing 16 changed files with 546 additions and 538 deletions.
2 changes: 1 addition & 1 deletion include/flc_algorithm.i
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ typedef int index_int;

// Give it a particularly named type in the Fortran proxy code.
%apply int { index_int };
%typemap(ftype, in={integer(INDEX_INT), intent(in)}) index_int
%typemap(ftype, in="integer(INDEX_INT), intent(in)") index_int
%{integer(INDEX_INT)%}

// Apply array-to-C translation for numeric values
Expand Down
10 changes: 7 additions & 3 deletions include/flc_string.i
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@

// Typemap to convert positions from npos -> 0 and 1-offset otherwise. Similar
// to
%apply int FORTRAN_INT { std::size_t POSITION };
%typemap(out, noblock=1) std::size_t POSITION {
%apply int FORTRAN_INT { size_t POSITION };
%typemap(out, noblock=1) size_t POSITION {
$result = ($1 == std::string::npos ? 0 : $1 + 1);
}

Expand All @@ -50,7 +50,7 @@ class string {
%apply int FORTRAN_INT {size_type};

// - Use fortran indexing (and 0 for not found) for search
%apply std::size_t POSITION {size_type find};
%apply size_t POSITION {size_type find};

// - Allow access as an array view
%apply SWIGTYPE& { string& view };
Expand Down Expand Up @@ -134,6 +134,10 @@ class string {
}
}

%fragment("<cctype>", "header") %{
#include <cctype>
%}

%fragment("flc_has_junk", "header",
fragment="<cctype>", fragment="<algorithm>") %{
SWIGINTERN bool flc_has_junk(const std::string& s, size_t pos) {
Expand Down
2 changes: 1 addition & 1 deletion src/flc.f90
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
! This file was automatically generated by SWIG (http://www.swig.org).
! Version 4.0.2+fortran
! Version 4.1.0+fortran
!
! Do not make changes to this file unless you know what you are doing--modify
! the SWIG interface file instead.
Expand Down
8 changes: 4 additions & 4 deletions src/flcFORTRAN_wrap.cxx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org).
* Version 4.0.2+fortran
* Version 4.1.0+fortran
*
* This file is not intended to be easily readable and contains a number of
* coding conventions designed to improve portability and efficiency. Do not make
Expand Down Expand Up @@ -226,7 +226,7 @@ SWIGEXPORT void SWIG_store_exception(const char* decl, int errcode, const char *
if (!(EXPR)) { SWIG_exception_impl("$decl", SWIG_ValueError, MSG, RETURNNULL); }


#define SWIGVERSION 0x040002
#define SWIGVERSION 0x040100
#define SWIG_VERSION SWIGVERSION


Expand Down Expand Up @@ -286,10 +286,10 @@ SWIGEXPORT const char* flc_get_serr() {
#include <string>


#include <cctype>
extern "C" {



extern "C" {
// Call this function before any new action
SWIGEXPORT void SWIG_check_unhandled_exception_impl(const char* decl) {
if (flc_ierr != 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/flc_algorithm.f90
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
! This file was automatically generated by SWIG (http://www.swig.org).
! Version 4.0.2+fortran
! Version 4.1.0+fortran
!
! Do not make changes to this file unless you know what you are doing--modify
! the SWIG interface file instead.
Expand Down
4 changes: 2 additions & 2 deletions src/flc_algorithmFORTRAN_wrap.cxx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org).
* Version 4.0.2+fortran
* Version 4.1.0+fortran
*
* This file is not intended to be easily readable and contains a number of
* coding conventions designed to improve portability and efficiency. Do not make
Expand Down Expand Up @@ -242,7 +242,7 @@ enum SwigMemFlags {
if (!(EXPR)) { SWIG_exception_impl("$decl", SWIG_ValueError, MSG, RETURNNULL); }


#define SWIGVERSION 0x040002
#define SWIGVERSION 0x040100
#define SWIG_VERSION SWIGVERSION


Expand Down
38 changes: 19 additions & 19 deletions src/flc_map.f90
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
! This file was automatically generated by SWIG (http://www.swig.org).
! Version 4.0.2+fortran
! Version 4.1.0+fortran
!
! Do not make changes to this file unless you know what you are doing--modify
! the SWIG interface file instead.
Expand Down Expand Up @@ -110,7 +110,7 @@ function swigc_MapIntInt_size(farg1) &
use, intrinsic :: ISO_C_BINDING
import :: swigclasswrapper
type(SwigClassWrapper), intent(in) :: farg1
integer(C_LONG) :: fresult
integer(C_SIZE_T) :: fresult
end function

subroutine swigc_MapIntInt_clear(farg1) &
Expand All @@ -127,7 +127,7 @@ function swigc_MapIntInt_erase(farg1, farg2) &
import :: swigclasswrapper
type(SwigClassWrapper), intent(in) :: farg1
integer(C_INT), intent(in) :: farg2
integer(C_LONG) :: fresult
integer(C_SIZE_T) :: fresult
end function

function swigc_MapIntInt_count(farg1, farg2) &
Expand All @@ -137,7 +137,7 @@ function swigc_MapIntInt_count(farg1, farg2) &
import :: swigclasswrapper
type(SwigClassWrapper), intent(in) :: farg1
integer(C_INT), intent(in) :: farg2
integer(C_LONG) :: fresult
integer(C_SIZE_T) :: fresult
end function

function swigc_MapIntInt_insert(farg1, farg2, farg3) &
Expand Down Expand Up @@ -208,7 +208,7 @@ function swigc_MapStringInt_size(farg1) &
use, intrinsic :: ISO_C_BINDING
import :: swigclasswrapper
type(SwigClassWrapper), intent(in) :: farg1
integer(C_LONG) :: fresult
integer(C_SIZE_T) :: fresult
end function

subroutine swigc_MapStringInt_clear(farg1) &
Expand All @@ -226,7 +226,7 @@ function swigc_MapStringInt_erase(farg1, farg2) &
import :: swigarraywrapper
type(SwigClassWrapper), intent(in) :: farg1
type(SwigArrayWrapper) :: farg2
integer(C_LONG) :: fresult
integer(C_SIZE_T) :: fresult
end function

function swigc_MapStringInt_count(farg1, farg2) &
Expand All @@ -237,7 +237,7 @@ function swigc_MapStringInt_count(farg1, farg2) &
import :: swigarraywrapper
type(SwigClassWrapper), intent(in) :: farg1
type(SwigArrayWrapper) :: farg2
integer(C_LONG) :: fresult
integer(C_SIZE_T) :: fresult
end function

function swigc_MapStringInt_insert(farg1, farg2, farg3) &
Expand Down Expand Up @@ -311,7 +311,7 @@ function swigc_MapStringString_size(farg1) &
use, intrinsic :: ISO_C_BINDING
import :: swigclasswrapper
type(SwigClassWrapper), intent(in) :: farg1
integer(C_LONG) :: fresult
integer(C_SIZE_T) :: fresult
end function

subroutine swigc_MapStringString_clear(farg1) &
Expand All @@ -329,7 +329,7 @@ function swigc_MapStringString_erase(farg1, farg2) &
import :: swigarraywrapper
type(SwigClassWrapper), intent(in) :: farg1
type(SwigArrayWrapper) :: farg2
integer(C_LONG) :: fresult
integer(C_SIZE_T) :: fresult
end function

function swigc_MapStringString_count(farg1, farg2) &
Expand All @@ -340,7 +340,7 @@ function swigc_MapStringString_count(farg1, farg2) &
import :: swigarraywrapper
type(SwigClassWrapper), intent(in) :: farg1
type(SwigArrayWrapper) :: farg2
integer(C_LONG) :: fresult
integer(C_SIZE_T) :: fresult
end function

function swigc_MapStringString_insert(farg1, farg2, farg3) &
Expand Down Expand Up @@ -437,7 +437,7 @@ function swigf_MapIntInt_size(self) &
use, intrinsic :: ISO_C_BINDING
integer :: swig_result
class(MapIntInt), intent(in) :: self
integer(C_LONG) :: fresult
integer(C_SIZE_T) :: fresult
type(SwigClassWrapper) :: farg1

farg1 = self%swigdata
Expand All @@ -459,7 +459,7 @@ subroutine swigf_MapIntInt_erase(self, x, swig_result)
class(MapIntInt), intent(in) :: self
integer(C_INT), intent(in) :: x
integer, intent(out), optional :: swig_result
integer(C_LONG) :: fresult
integer(C_SIZE_T) :: fresult
type(SwigClassWrapper) :: farg1
integer(C_INT) :: farg2

Expand All @@ -478,7 +478,7 @@ function swigf_MapIntInt_count(self, x) &
integer :: swig_result
class(MapIntInt), intent(in) :: self
integer(C_INT), intent(in) :: x
integer(C_LONG) :: fresult
integer(C_SIZE_T) :: fresult
type(SwigClassWrapper) :: farg1
integer(C_INT) :: farg2

Expand Down Expand Up @@ -595,7 +595,7 @@ function swigf_MapStringInt_size(self) &
use, intrinsic :: ISO_C_BINDING
integer :: swig_result
class(MapStringInt), intent(in) :: self
integer(C_LONG) :: fresult
integer(C_SIZE_T) :: fresult
type(SwigClassWrapper) :: farg1

farg1 = self%swigdata
Expand Down Expand Up @@ -635,7 +635,7 @@ subroutine swigf_MapStringInt_erase(self, x, swig_result)
class(MapStringInt), intent(in) :: self
character(len=*), target :: x
integer, intent(out), optional :: swig_result
integer(C_LONG) :: fresult
integer(C_SIZE_T) :: fresult
type(SwigClassWrapper) :: farg1
character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_temp
type(SwigArrayWrapper) :: farg2
Expand All @@ -655,7 +655,7 @@ function swigf_MapStringInt_count(self, x) &
integer :: swig_result
class(MapStringInt), intent(in) :: self
character(len=*), target :: x
integer(C_LONG) :: fresult
integer(C_SIZE_T) :: fresult
type(SwigClassWrapper) :: farg1
character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_temp
type(SwigArrayWrapper) :: farg2
Expand Down Expand Up @@ -776,7 +776,7 @@ function swigf_MapStringString_size(self) &
use, intrinsic :: ISO_C_BINDING
integer :: swig_result
class(MapStringString), intent(in) :: self
integer(C_LONG) :: fresult
integer(C_SIZE_T) :: fresult
type(SwigClassWrapper) :: farg1

farg1 = self%swigdata
Expand All @@ -798,7 +798,7 @@ subroutine swigf_MapStringString_erase(self, x, swig_result)
class(MapStringString), intent(in) :: self
character(len=*), target :: x
integer, intent(out), optional :: swig_result
integer(C_LONG) :: fresult
integer(C_SIZE_T) :: fresult
type(SwigClassWrapper) :: farg1
character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_temp
type(SwigArrayWrapper) :: farg2
Expand All @@ -818,7 +818,7 @@ function swigf_MapStringString_count(self, x) &
integer :: swig_result
class(MapStringString), intent(in) :: self
character(len=*), target :: x
integer(C_LONG) :: fresult
integer(C_SIZE_T) :: fresult
type(SwigClassWrapper) :: farg1
character(kind=C_CHAR), dimension(:), allocatable, target :: farg2_temp
type(SwigArrayWrapper) :: farg2
Expand Down
Loading

0 comments on commit 0ada9ff

Please sign in to comment.