Skip to content

Commit

Permalink
(piqi) Change "piqi expand" to use extended Piqi imports and functions
Browse files Browse the repository at this point in the history
This is the default behavior when --include-only flag is not specified
  • Loading branch information
alavrik committed Mar 25, 2012
1 parent 8c28798 commit a1dfccd
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 9 deletions.
23 changes: 19 additions & 4 deletions piqicc/boot/piqi_piqi.ml
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,9 @@ and
mutable resolved_piqdef : Piqtype.piqdef list;
mutable imported_piqdef : Piqtype.piqdef list;
mutable resolved_import : Piqtype.import list;
mutable extended_import : Piqtype.import list;
mutable resolved_func : Piqtype.func list;
mutable extended_func : Piqtype.func list;
mutable included_piqi : Piqtype.piqi list;
mutable original_piqi : Piqtype.piqi option;
mutable ast : Piqtype.ast option;
Expand Down Expand Up @@ -558,6 +560,8 @@ and parse_piqi x =
(let (_ast, x) = Piqirun.parse_optional_field 4849474 parse_ast x in
let (_modname, x) =
Piqirun.parse_optional_field 13841580 parse_word x in
let (_extended_func, x) =
Piqirun.parse_repeated_field 79393432 parse_func x in
let (_resolved_piqdef, x) =
Piqirun.parse_repeated_field 106036066 parse_piqdef x in
let (_resolved_import, x) =
Expand Down Expand Up @@ -588,13 +592,16 @@ and parse_piqi x =
Piqirun.parse_repeated_field 405875126 parse_string x in
let (_extended_piqdef, x) =
Piqirun.parse_repeated_field 422489281 parse_piqdef x in
let (_extended_import, x) =
Piqirun.parse_repeated_field 430482873 parse_import x in
let (_original_piqi, x) =
Piqirun.parse_optional_field 455316941 parse_piqi x
in
(Piqirun.check_unparsed_fields x;
{
Piqi.ast = _ast;
Piqi.modname = _modname;
Piqi.extended_func = _extended_func;
Piqi.resolved_piqdef = _resolved_piqdef;
Piqi.resolved_import = _resolved_import;
Piqi.extend = _extend;
Expand All @@ -610,6 +617,7 @@ and parse_piqi x =
Piqi.ocaml_module = _ocaml_module;
Piqi.proto_custom = _proto_custom;
Piqi.extended_piqdef = _extended_piqdef;
Piqi.extended_import = _extended_import;
Piqi.original_piqi = _original_piqi;
}))
and parse_piqdef x =
Expand Down Expand Up @@ -1221,6 +1229,8 @@ and gen__piqi code x =
let _ast = Piqirun.gen_optional_field 4849474 gen__ast x.Piqi.ast in
let _modname =
Piqirun.gen_optional_field 13841580 gen__word x.Piqi.modname in
let _extended_func =
Piqirun.gen_repeated_field 79393432 gen__func x.Piqi.extended_func in
let _resolved_piqdef =
Piqirun.gen_repeated_field 106036066 gen__piqdef x.Piqi.resolved_piqdef in
let _resolved_import =
Expand Down Expand Up @@ -1250,14 +1260,17 @@ and gen__piqi code x =
Piqirun.gen_repeated_field 405875126 gen__string x.Piqi.proto_custom in
let _extended_piqdef =
Piqirun.gen_repeated_field 422489281 gen__piqdef x.Piqi.extended_piqdef in
let _extended_import =
Piqirun.gen_repeated_field 430482873 gen__import x.Piqi.extended_import in
let _original_piqi =
Piqirun.gen_optional_field 455316941 gen__piqi x.Piqi.original_piqi
in
Piqirun.gen_record code
[ _ast; _modname; _resolved_piqdef; _resolved_import; _extend;
_piqdef; _import; _included_piqi; _custom_field; _resolved_func;
_includ; _imported_piqdef; _proto_package; _func; _ocaml_module;
_proto_custom; _extended_piqdef; _original_piqi ])
[ _ast; _modname; _extended_func; _resolved_piqdef; _resolved_import;
_extend; _piqdef; _import; _included_piqi; _custom_field;
_resolved_func; _includ; _imported_piqdef; _proto_package; _func;
_ocaml_module; _proto_custom; _extended_piqdef; _extended_import;
_original_piqi ])
and gen__piqdef code (x : Piqtype.piqdef) =
(refer x;
Piqirun.gen_record code
Expand Down Expand Up @@ -1642,6 +1655,7 @@ and default_piqi () =
{
Piqi.ast = None;
Piqi.modname = None;
Piqi.extended_func = [];
Piqi.resolved_piqdef = [];
Piqi.resolved_import = [];
Piqi.extend = [];
Expand All @@ -1657,6 +1671,7 @@ and default_piqi () =
Piqi.ocaml_module = None;
Piqi.proto_custom = [];
Piqi.extended_piqdef = [];
Piqi.extended_import = [];
Piqi.original_piqi = None;
}
and default_piqdef () = `record (default_record ())
Expand Down
5 changes: 5 additions & 0 deletions piqilib/piqi-impl.piqi
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,13 @@
.with.field [ .name extended-piqdef .type piqdef .repeated ]
.with.field [ .name resolved-piqdef .type piqdef .repeated ]
.with.field [ .name imported-piqdef .type piqdef .repeated ]

.with.field [ .name resolved-import .type import .repeated ]
.with.field [ .name extended-import .type import .repeated ]

.with.field [ .name resolved-func .type function .repeated ]
.with.field [ .name extended-func .type function .repeated ]

.with.field [ .name included-piqi .type piqi .repeated ]

.with.field [ .name original-piqi .type piqi .optional ]
Expand Down
19 changes: 14 additions & 5 deletions piqilib/piqi.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1387,6 +1387,7 @@ let rec process_piqi ?modname ?(include_path=[]) ?(fname="") ?(ast: T.ast option
let resolved_imports = copy_imports extended_imports in
load_imports piqi resolved_imports;
piqi.P#resolved_import <- resolved_imports;
piqi.P#extended_import <- extended_imports;

(*
* handle imported defs
Expand Down Expand Up @@ -1430,6 +1431,7 @@ let rec process_piqi ?modname ?(include_path=[]) ?(fname="") ?(ast: T.ast option
(* preserve the original functions *)
let resolved_funs = List.map copy_obj extended_funs in
piqi.P#resolved_func <- resolved_funs;
piqi.P#extended_func <- extended_funs;

(* get definitions derived from function parameters *)
let func_defs, func_defs_map = get_function_defs resolved_funs in
Expand Down Expand Up @@ -1857,18 +1859,25 @@ let expand_piqi ?(includes_only=false) piqi =
custom_field = [];
includ = [];

extend =
if includes_only
then piqi.extend (* all extensions *)
else []; (* extensions are already applied *)

piqdef =
if includes_only
then piqi.piqdef (* all typedefs *)
else piqi.extended_piqdef; (* all typedefs with extensions applied *)

extend =
import =
if includes_only
then piqi.extend (* all extensions *)
else []; (* extensions are already applied *)
then piqi.import
else piqi.extended_import; (* all imports with extensions applied *)

import = piqi.import;
func = piqi.func;
func =
if includes_only
then piqi.func
else piqi.extended_func; (* all functions with extensions applied *)
}
in
res_piqi
Expand Down

0 comments on commit a1dfccd

Please sign in to comment.