Skip to content

Commit acf840e

Browse files
committed
Merge branch 'master' of https://github.com/jacobwilliams/json-fortran into coverage
2 parents a101f35 + 46bf070 commit acf840e

24 files changed

+429
-298
lines changed

CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,12 @@ message ( STATUS "CMake build configuration for JSON-Fortran ${VERSION_MAJOR}.${
4444
#-------------------------------------
4545
# Collect source files for the library
4646
#-------------------------------------
47-
set ( JF_LIB_SRCS src/json_module.F90 )
47+
set ( JF_LIB_SRCS src/json_kinds.F90
48+
src/json_parameters.F90
49+
src/json_string_utilities.F90
50+
src/json_value_module.F90
51+
src/json_file_module.F90
52+
src/json_module.F90 )
4853
file ( GLOB JF_TEST_SRCS "src/tests/jf_test_*.f90" )
4954
set ( JF_TEST_UCS4_SUPPORT_SRC "${CMAKE_SOURCE_DIR}/src/tests/introspection/test_iso_10646_support.f90")
5055

json-fortran.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ display: public
2020
private
2121
source: true
2222
graph: true
23+
exclude_dir: tests
2324
extra_mods: iso_fortran_env:https://gcc.gnu.org/onlinedocs/gfortran/ISO_005fFORTRAN_005fENV.html
24-
md_extensions: markdown.extensions.toc(anchorlink=True)
25-
markdown.extensions.smarty(smart_quotes=False)
25+
md_extensions: markdown.extensions.smarty(smart_quotes=False)
2626
---
2727

2828
--------------------

src/json_file_module.F90

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,9 @@ end subroutine json_file_print_error_message
241241
!
242242
!@note: This does not destroy the data in the file.
243243

244-
subroutine initialize_json_core_in_file(me,verbose,compact_reals,print_signs,real_format,spaces_per_tab)
244+
subroutine initialize_json_core_in_file(me,verbose,compact_reals,&
245+
print_signs,real_format,spaces_per_tab,&
246+
strict_type_checking)
245247

246248
implicit none
247249

@@ -251,8 +253,13 @@ subroutine initialize_json_core_in_file(me,verbose,compact_reals,print_signs,rea
251253
logical(LK),intent(in),optional :: print_signs !! always print numeric sign (default is false)
252254
character(len=*,kind=CDK),intent(in),optional :: real_format !! Real number format: 'E' [default], '*', 'G', 'EN', or 'ES'
253255
integer,intent(in),optional :: spaces_per_tab !! number of spaces per tab for indenting (default is 2)
256+
logical(LK),intent(in),optional :: strict_type_checking !! if true, no integer, double, or logical type
257+
!! conversions are done for the `get` routines
258+
!! (default is false)
254259

255-
call me%json%initialize(verbose,compact_reals,print_signs,real_format,spaces_per_tab)
260+
call me%json%initialize(verbose,compact_reals,&
261+
print_signs,real_format,spaces_per_tab,&
262+
strict_type_checking)
256263

257264
end subroutine initialize_json_core_in_file
258265
!*****************************************************************************************
@@ -264,7 +271,9 @@ end subroutine initialize_json_core_in_file
264271
! Cast a [[json_value]] object as a [[json_file(type)]] object.
265272
! It also calls the `initialize()` method.
266273

267-
function initialize_json_file(p,verbose,compact_reals,print_signs,real_format,spaces_per_tab) result(file_object)
274+
function initialize_json_file(p,verbose,compact_reals,&
275+
print_signs,real_format,spaces_per_tab,&
276+
strict_type_checking) result(file_object)
268277

269278
implicit none
270279

@@ -276,8 +285,13 @@ function initialize_json_file(p,verbose,compact_reals,print_signs,real_format,sp
276285
logical(LK),intent(in),optional :: print_signs !! always print numeric sign (default is false)
277286
character(len=*,kind=CDK),intent(in),optional :: real_format !! Real number format: 'E' [default], '*', 'G', 'EN', or 'ES'
278287
integer,intent(in),optional :: spaces_per_tab !! number of spaces per tab for indenting (default is 2)
288+
logical(LK),intent(in),optional :: strict_type_checking !! if true, no integer, double, or logical type
289+
!! conversions are done for the `get` routines
290+
!! (default is false)
279291

280-
call file_object%initialize(verbose,compact_reals,print_signs,real_format,spaces_per_tab)
292+
call file_object%initialize(verbose,compact_reals,&
293+
print_signs,real_format,spaces_per_tab,&
294+
strict_type_checking)
281295

282296
if (present(p)) file_object%p => p
283297

src/json_macros.inc

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
!*****************************************************************************************
2-
!>
3-
! JSON-Fortran preprocessor macros.
1+
! JSON-Fortran preprocessor macros.
42
!
5-
!## License
6-
! * JSON-Fortran is released under a BSD-style license.
7-
! See the [LICENSE](https://github.com/jacobwilliams/json-fortran/blob/master/LICENSE)
8-
! file for details.
3+
! License
4+
! JSON-Fortran is released under a BSD-style license.
5+
! See the [LICENSE](https://github.com/jacobwilliams/json-fortran/blob/master/LICENSE)
6+
! file for details.
97

108
!*********************************************************
119
! File encoding preprocessor macro.

src/json_module.F90

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,32 @@
44
!
55
! A Fortran 2008 JSON (JavaScript Object Notation) API.
66
!
7-
! This module provides access to [[json_kinds]], [[json_value_module]] and
8-
! [[json_file_module]]. Either one can be used separately, or all can be
9-
! used by using this module.
7+
! This module provides access to [[json_value_module]] and
8+
! [[json_file_module]]. For normal JSON-Fortran use, using this module
9+
! is all that is necessary.
10+
!
11+
! Note that this module renames the kind definition variables from [[json_kinds]]
12+
! from [`RK`, `IK`, `LK`, `CK`, and `CDK`] to [`json_RK`, `json_IK`, `json_LK`,
13+
! `json_CK`, and `json_CDK`] so as to avoid namespace pollution with short
14+
! variable names.
15+
!
16+
#ifdef USE_UCS4
17+
#pragma push_macro("USE_UCS4")
18+
#undef USE_UCS4
19+
! Since ```USE_UCS4``` **is** defined, this module also exports the
20+
! operators `==`, `/=`, and `//` from [[json_string_utilities]] for
21+
! `CK` and `CDK` operations.
22+
#pragma pop_macro("USE_UCS4")
23+
#endif
1024
!
1125
!## License
1226
! * JSON-Fortran is released under a BSD-style license.
1327
! See the [LICENSE](https://github.com/jacobwilliams/json-fortran/blob/master/LICENSE)
1428
! file for details.
1529
!
1630
!## History
17-
! * Joseph A. Levin : March 2012 : Original FSON code [retrieved on 12/2/2013].
31+
! * Joseph A. Levin : March 2012 : Original [FSON](https://github.com/josephalevin/fson)
32+
! code [retrieved on 12/2/2013].
1833
! * Jacob Williams : 2/8/2014 : Extensive modifications to the original FSON code.
1934
! The original F95 code was split into four files:
2035
! fson_path_m.f95, fson_string_m.f95, fson_value_m.f95, and fson.f95.
@@ -34,7 +49,16 @@
3449

3550
module json_module
3651

37-
use json_kinds
52+
use json_kinds, only: json_RK => RK, &
53+
json_IK => IK, &
54+
json_LK => LK, &
55+
json_CK => CK, &
56+
json_CDK => CDK
57+
#ifdef USE_UCS4
58+
use json_string_utilities, only: operator(==),&
59+
operator(//),&
60+
operator(/=)
61+
#endif
3862
use json_value_module
3963
use json_file_module
4064

src/json_parameters.F90

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ module json_parameters
4343
character(kind=CK,len=*),parameter :: backslash = achar(92)
4444

4545
character(kind=CDK,len=*),parameter,public :: default_real_fmt = '(ss,E26.16E4)'
46-
!! default real number format statement
46+
!! default real number format statement (for writing real values to strings and files).
47+
!! Note that this can be overridden by calling [[json_initialize]].
4748

4849
character(kind=CK,len=*),parameter,public :: star = '*' !! for invalid numbers and
4950
!! list-directed real output
@@ -56,9 +57,9 @@ module json_parameters
5657

5758
!These were parameters, but gfortran bug (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65141)
5859
!necessitates moving them here to be variables
59-
character(kind=CK,len=4),protected :: null_str = 'null'
60-
character(kind=CK,len=4),protected :: true_str = 'true'
61-
character(kind=CK,len=5),protected :: false_str = 'false'
60+
character(kind=CK,len=4),protected :: null_str = 'null' !! JSON Null variable string
61+
character(kind=CK,len=4),protected :: true_str = 'true' !! JSON logical True string
62+
character(kind=CK,len=5),protected :: false_str = 'false' !! JSON logical False string
6263

6364
integer, private :: i_ !! just a counter for control_chars array
6465
character(kind=CK,len=*),dimension(32),parameter :: control_chars = &

0 commit comments

Comments
 (0)