Add structs.
[wrappi.git] / generator-lib / wrappi_types.ml
index 588ad70..84e008c 100644 (file)
@@ -44,11 +44,14 @@ type prec
 
 type parameter = string * ptype * prec option
 
-type rtype = RVoid | Return of ptype
+type rtype = RVoid | RStaticString | Return of ptype
 
 type ftype = rtype * parameter list * parameter list
 
-type c_code = string
+type c_code = {
+  cc_loc : Camlp4.PreCast.Loc.t;
+  cc_code : string;
+}
 
 type entry_point = {
   ep_loc : Camlp4.PreCast.Loc.t;
@@ -56,6 +59,7 @@ type entry_point = {
   ep_name : string;
   ep_ftype : ftype;
   ep_code : c_code option;
+  ep_includes : string list;
 }
 
 type typedef = {
@@ -73,15 +77,13 @@ type enum = {
 type struct_decl = {
   sd_loc : Camlp4.PreCast.Loc.t;
   sd_name : string;
-  sd_identifiers : string array;
-  sd_fields : ptype array;
+  sd_fields : (string * ptype) array;
 }
 
 type union = {
   un_loc : Camlp4.PreCast.Loc.t;
   un_name : string;
-  un_identifiers : string array;
-  un_fields : ptype array;
+  un_fields : (string * ptype) array;
 }
 
 type api = {
@@ -123,6 +125,7 @@ let rec string_of_ptype = function
   | TUnion name -> sprintf "union %s" name
 let string_of_rtype = function
   | RVoid -> "void"
+  | RStaticString -> "static_string"
   | Return t -> string_of_ptype t
 let string_of_parameter (name, t, _) =
   sprintf "%s %s" (string_of_ptype t) name
@@ -131,7 +134,7 @@ let string_of_parameters params =
 let string_of_ftype (ret, req, opt) =
   sprintf "%s %s %s"
     (string_of_rtype ret) (string_of_parameters req) (string_of_parameters opt)
-let string_of_c_code code = code
+let string_of_c_code code = code.cc_code
 
 let string_of_typedef td =
   sprintf "typedef %s %s" td.td_name (string_of_ptype td.td_type)