git.annexia.org
/
wrappi.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add LGPLv2+ notice to *.api files.
[wrappi.git]
/
generator-macros
/
pa_wrap.ml
diff --git
a/generator-macros/pa_wrap.ml
b/generator-macros/pa_wrap.ml
index
b4fea3a
..
ffd9e6b
100644
(file)
--- a/
generator-macros/pa_wrap.ml
+++ b/
generator-macros/pa_wrap.ml
@@
-51,9
+51,12
@@
let expr_of_loc _loc loc =
$`int:stop_line$, $`int:stop_bol$, $`int:stop_off$,
$`bool:ghost$) >>
$`int:stop_line$, $`int:stop_bol$, $`int:stop_off$,
$`bool:ghost$) >>
-let add_entry_point _loc name parameters rtype code =
+let add_entry_point _loc
local
name parameters rtype code =
let loc = expr_of_loc _loc _loc in
let loc = expr_of_loc _loc _loc in
+ let local =
+ match local with None -> <:expr< false >> | _ -> <:expr< true >> in
+
let parameters = List.map (
fun (name, t) -> <:expr< ($str:name$, $t$, None) >>
) parameters in
let parameters = List.map (
fun (name, t) -> <:expr< ($str:name$, $t$, None) >>
) parameters in
@@
-63,6
+66,7
@@
let add_entry_point _loc name parameters rtype code =
<:str_item<
let ep = { Wrappi_types.ep_loc = $loc$;
<:str_item<
let ep = { Wrappi_types.ep_loc = $loc$;
+ ep_local = $local$;
ep_name = $str:name$;
ep_ftype = ($rtype$, $parameters$, []);
ep_code = $code$ } in
ep_name = $str:name$;
ep_ftype = ($rtype$, $parameters$, []);
ep_code = $code$ } in
@@
-99,7
+103,9
@@
EXTEND Gram
(* A parameter or return type. *)
ptype: [
(* A parameter or return type. *)
ptype: [
- [ "buffer" -> <:expr< Wrappi_types.TBuffer >> ]
+ [ "bool" -> <:expr< Wrappi_types.TBool >> ]
+ | [ "buffer" -> <:expr< Wrappi_types.TBuffer >> ]
+ (* enum XXX *)
| [ "file" -> <:expr< Wrappi_types.TFile >> ]
| [ "hash"; "("; t = ptype; ")" -> <:expr< Wrappi_types.THash $t$ >> ]
| [ "int" -> <:expr< Wrappi_types.TInt >> ]
| [ "file" -> <:expr< Wrappi_types.TFile >> ]
| [ "hash"; "("; t = ptype; ")" -> <:expr< Wrappi_types.THash $t$ >> ]
| [ "int" -> <:expr< Wrappi_types.TInt >> ]
@@
-111,12
+117,13
@@
EXTEND Gram
| [ "struct"; name = LIDENT -> <:expr< Wrappi_types.TStruct $str:name$ >> ]
| [ "uint32" -> <:expr< Wrappi_types.TUInt32 >> ]
| [ "uint64" -> <:expr< Wrappi_types.TUInt64 >> ]
| [ "struct"; name = LIDENT -> <:expr< Wrappi_types.TStruct $str:name$ >> ]
| [ "uint32" -> <:expr< Wrappi_types.TUInt32 >> ]
| [ "uint64" -> <:expr< Wrappi_types.TUInt64 >> ]
+ (* union XXX *)
| [ name = LIDENT -> <:expr< Wrappi_types.TTypedef $str:name$ >> ]
];
(* A return type. *)
rtype: [
| [ name = LIDENT -> <:expr< Wrappi_types.TTypedef $str:name$ >> ]
];
(* A return type. *)
rtype: [
- [ "
err" -> <:expr< Wrappi_types.RErr
>> ]
+ [ "
void" -> <:expr< Wrappi_types.RVoid
>> ]
| [ t = ptype -> <:expr< Wrappi_types.Return $t$ >> ]
];
| [ t = ptype -> <:expr< Wrappi_types.Return $t$ >> ]
];
@@
-125,10
+132,11
@@
EXTEND Gram
str_item: LEVEL "top" [
[ "entry_point";
str_item: LEVEL "top" [
[ "entry_point";
+ local = OPT "local";
rtype = rtype; name = LIDENT;
"("; parameters = LIST0 parameter SEP ","; ")";
code = OPT [ code = expr -> code ] ->
rtype = rtype; name = LIDENT;
"("; parameters = LIST0 parameter SEP ","; ")";
code = OPT [ code = expr -> code ] ->
- add_entry_point _loc name parameters rtype code
+ add_entry_point _loc
local
name parameters rtype code
]
| [ "typedef"; t = ptype; name = LIDENT ->
add_typedef _loc name t
]
| [ "typedef"; t = ptype; name = LIDENT ->
add_typedef _loc name t