--- TODO | 6 ------ generator/state_machine_generator.ml | 2 ++ generator/utils.ml | 2 ++ generator/utils.mli | 1 + 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/TODO b/TODO index 3861edc40..39642bc15 100644 --- a/TODO +++ b/TODO @@ -5,12 +5,6 @@ Bindings in other languages. - Latest attempt at adding Rust: https://www.redhat.com/archives/libguestfs/2019-August/msg00416.html -Additional #line directives in generated lib/states.c that track -position of output file when no longer copying lines from -generator/states-*.c. Probably requires moving type location, noloc, -and line_directive_of_location to utils.ml, and teaching pr to track -lines as well as columns. - Example code integrating with ppoll, pollfd, APR pollset (and others?). NBD resize extension. diff --git a/generator/state_machine_generator.ml b/generator/state_machine_generator.ml index 4e4751b76..2f4837f85 100644 --- a/generator/state_machine_generator.ml +++ b/generator/state_machine_generator.ml @@ -360,6 +360,8 @@ let generate_lib_states_c () = pr " return 0;\n"; pr "}\n"; pr "\n"; + let output_loc = "lib/states.c", output_lineno () in + pr "%s\n" (line_directive_of_location output_loc); pr "int\n"; pr "nbd_internal_enter_%s (struct nbd_handle *h, bool *blocked)\n" state_enum; diff --git a/generator/utils.ml b/generator/utils.ml index 48669f9b7..499e8f8ec 100644 --- a/generator/utils.ml +++ b/generator/utils.ml @@ -190,6 +190,8 @@ let pr_wrap ?(maxcol = 76) c code = *) pr "%s" (String.concat "\n" rest) +let output_lineno () = !lineno + let string_of_location (file, lineno) = sprintf "%s:%d" file lineno let line_directive_of_location (file, lineno) = sprintf "#line %d \"%s\"" lineno file diff --git a/generator/utils.mli b/generator/utils.mli index c6ed61ce0..21afe5529 100644 --- a/generator/utils.mli +++ b/generator/utils.mli @@ -52,6 +52,7 @@ val generate_header : ?extra_sources:string list -> comment_style -> unit val output_to : string -> (unit -> 'a) -> unit val pr : ('a, unit, string, unit) format4 -> 'a val pr_wrap : ?maxcol:int -> char -> (unit -> 'a) -> unit +val output_lineno : unit -> int val noloc : location val string_of_location : location -> string -- 2.32.0