Commit 680a05bb authored by Daniel Nemergut's avatar Daniel Nemergut
Browse files

Renamed some vars for my own sanity

parent d8c4adc0
Loading
Loading
Loading
Loading
+13 −12
Original line number Diff line number Diff line
@@ -8,12 +8,13 @@ c_file = "cdict_fortran_api"
f_file = "cdict_fortran_interface.F03"

# Supported types, using a dict, heh...
#   nickname: c_type, f_type, binding_type
#   nickname: [c_type, f_type, binding_type]
c_types = {
    "f": ["float", "real", "c_float"],
    "d": ["double", "real", "c_double"],
    "i": ["int", "integer", "c_int"],
    "b": ["Boolean", "logical", "c_bool"]
    "b": ["Boolean", "logical", "c_bool"],
    "p": ["void *", "type", "c_ptr"]
}

# C Header
@@ -51,12 +52,12 @@ void f_cdict_free(struct cdict_t * c);
""")

    # Cdict_set for each type pair
    for nnA, typeA in c_types.items():
        for nnB, typeB in c_types.items():
    for nnkey, typekey in c_types.items():
        for nnval, typeval in c_types.items():
            f.write("""
CDict_API_function
void f_cdict_set_{}_{}(struct cdict_t * c, {} k, {} v);
""".format(nnA, nnB, typeA[0], typeB[0]))
""".format(nnkey, nnval, typekey[0], typeval[0]))

    f.write("""
#endif //LIBCDICT_CDICT_FORTRAN_API_H
@@ -102,14 +103,14 @@ void f_cdict_free(struct cdict_t * c) {
""")

    # Cdict_set for each type pair
    for nnA, typeA in c_types.items():
        for nnB, typeB in c_types.items():
    for nnkey, typekey in c_types.items():
        for nnval, typeval in c_types.items():
            f.write("""
CDict_API_function
void f_cdict_set_{}_{}(struct cdict_t * c, {} k, {} v) {{
    CDict_set(c,k,v);
}}
""".format(nnA, nnB, typeA[0], typeB[0]))
""".format(nnkey, nnval, typekey[0], typeval[0]))

# F module
with open(f_file, 'w') as f:
@@ -206,9 +207,9 @@ module libcdict_m
    ! Set
    interface f_cdict_set""")

    # Cdict_set for each type pair
    for nnA, typeA in c_types.items():
        for nnB, typeB in c_types.items():
    # CDict_set for each type pair
    for nnkey, typekey in c_types.items():
        for nnval, typeval in c_types.items():
            f.write("""
        subroutine f_cdict_set_{}_{}(cdict, key, value) bind(c,name="f_cdict_set_{}_{}")
            use, intrinsic :: iso_c_binding
@@ -216,7 +217,7 @@ module libcdict_m
            {}({}), intent(in), VALUE :: key
            {}({}), intent(in), VALUE :: value
        end subroutine f_cdict_set_{}_{}
""".format(nnA, nnB, nnA, nnB, typeA[1], typeA[2], typeB[1], typeB[2], nnA, nnB))
""".format(nnkey, nnval, nnkey, nnval, typekey[1], typekey[2], typeval[1], typeval[2], nnkey, nnval))

    f.write("""    end interface f_cdict_set
""")