@@ -438,9 +438,11 @@ struct Registry
438438 std::map<std::string, std::shared_ptr<InterfaceData>, ci_less> interface_map;
439439 std::map<std::string, std::shared_ptr<Module>, ci_less> modules;
440440 std::map<std::string, std::shared_ptr<DataType>, ci_less> data_types;
441+ std::map<std::string, std::shared_ptr<DataType>, ci_less> data_types_isocbinding;
441442 bool gen_c_code = false ;
442443 bool no_extrap_interp = false ;
443444 bool gen_inc_subs = false ;
445+ bool use_isocbinding = false ;
444446
445447 Registry ()
446448 {
@@ -453,6 +455,10 @@ struct Registry
453455 auto R8Ki = std::make_shared<DataType>(" R8Ki" , " REAL(R8Ki)" , DataType::Tag::Real, 64 );
454456 auto DbKi = std::make_shared<DataType>(" DbKi" , " REAL(DbKi)" , DataType::Tag::Real, 64 );
455457 auto logical = std::make_shared<DataType>(" Logical" , " LOGICAL" , DataType::Tag::Logical);
458+ auto c_int = std::make_shared<DataType>(" c_int" , " INTEGER(c_int)" , DataType::Tag::Integer, 32 );
459+ auto c_float = std::make_shared<DataType>(" c_float" , " REAL(c_float)" , DataType::Tag::Real, 32 );
460+ auto c_double = std::make_shared<DataType>(" c_double" ," REAL(c_double)" , DataType::Tag::Real, 64 );
461+ auto c_char = std::make_shared<DataType>(" c_char" , " CHARACTER(c_char)" , DataType::Tag::Character);
456462
457463 // Derived types
458464 auto mesh = std::make_shared<DataType>(nullptr , " MeshType" , " MeshType" , " MeshType" );
@@ -473,6 +479,10 @@ struct Registry
473479 {" logical" , logical},
474480 {" meshtype" , mesh},
475481 {" dll_type" , dll},
482+ {" c_int" ,c_int},
483+ {" c_float" ,c_float},
484+ {" c_double" ,c_double},
485+ {" c_char" ,c_char},
476486 };
477487
478488 this ->interface_map = std::map<std::string, std::shared_ptr<InterfaceData>, ci_less>{
@@ -500,6 +510,15 @@ struct Registry
500510 {" PartialConstrStatePInputType" ,
501511 std::make_shared<InterfaceData>(" PartialConstrStatePInputType" , " dZdu" , true )},
502512 };
513+
514+ // Map of ISO_C_BINDING types (for checks only)
515+ this ->data_types_isocbinding = std::map<std::string, std::shared_ptr<DataType>, ci_less>{
516+ {" c_int" ,c_int},
517+ {" c_float" ,c_float},
518+ {" c_double" ,c_double},
519+ {" c_char" ,c_char},
520+ };
521+
503522 }
504523
505524 // Parsing
@@ -512,12 +531,20 @@ struct Registry
512531 // Pointer to type
513532 std::shared_ptr<DataType> data_type;
514533
534+ // if using ISO_C_BINDING, search these types first
535+ auto it = data_types_isocbinding.find (type_name);
536+ if (it != data_types_isocbinding.end ())
537+ {
538+ this ->use_isocbinding = true ;
539+ return it->second ;
540+ }
541+
515542 // Get map of data types to search
516543 // If module was provided, search it; otherwise, search registry
517544 auto &data_types = mod == nullptr ? this ->data_types : mod->data_types ;
518545
519546 // Search for type in registry, return if found
520- auto it = data_types.find (type_name);
547+ it = data_types.find (type_name);
521548 if (it != data_types.end ())
522549 {
523550 return it->second ;
0 commit comments