X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=generator-macros%2Fpa_wrap.ml;h=a73484a46a41c73459aa451d23c671ac98872749;hb=68483fce4f959886866af28c1c3342c2a6fcb410;hp=54e36764715d83c3abe842dfc5c6e52531c3ba89;hpb=bb1329db94910f6739c839bee52177f1b3c4e695;p=wrappi.git diff --git a/generator-macros/pa_wrap.ml b/generator-macros/pa_wrap.ml index 54e3676..a73484a 100644 --- a/generator-macros/pa_wrap.ml +++ b/generator-macros/pa_wrap.ml @@ -39,6 +39,18 @@ let expr_of_option _loc = function | None -> <:expr< None >> | Some x -> <:expr< Some $x$ >> +(* Convert a _loc to an AST. *) +let expr_of_loc _loc loc = + let file_name, + start_line, start_bol, start_off, + stop_line, stop_bol, stop_off, + ghost = Loc.to_tuple loc in + <:expr< Camlp4.PreCast.Loc.of_tuple + ($str:file_name$, + $`int:start_line$, $`int:start_bol$, $`int:start_off$, + $`int:stop_line$, $`int:stop_bol$, $`int:stop_off$, + $`bool:ghost$) >> + let add_entry_point _loc name parameters return_type code = let parameters = List.map ( fun (name, t) -> <:expr< ($str:name$, $t$) >> @@ -47,8 +59,11 @@ let add_entry_point _loc name parameters return_type code = let code = expr_of_option _loc code in + let loc = expr_of_loc _loc _loc in + <:str_item< - let ep = { Wrappi_types.ep_name = $str:name$; + let ep = { Wrappi_types.ep_loc = $loc$; + ep_name = $str:name$; ep_params = $parameters$; ep_return = $return_type$; ep_code = $code$ } in @@ -75,9 +90,12 @@ EXTEND Gram (* A parameter or return type. *) any_type: [ - [ "int32" -> <:expr< Wrappi_types.TInt32 >> ] + [ "fileperm" -> <:expr< Wrappi_types.TFilePerm >> ] + | [ "int32" -> <:expr< Wrappi_types.TInt32 >> ] | [ "int64" -> <:expr< Wrappi_types.TInt64 >> ] - | [ t = LIDENT -> <:expr< Wrappi_types.Type $str:t$ >> ] + | [ "pathname" -> <:expr< Wrappi_types.TPathname >> ] + | [ "uint32" -> <:expr< Wrappi_types.TUInt32 >> ] + | [ "uint64" -> <:expr< Wrappi_types.TUInt64 >> ] ]; (* A return type. *)