static string internal_header_filename;
static string internal_vapi_filename;
static string fast_vapi_filename;
+ static bool vapi_comments;
static string symbols_filename;
static string includedir;
static bool compile_only;
{ "internal-vapi", 0, 0, OptionArg.FILENAME, ref internal_vapi_filename, "Output vapi with internal api", "FILE" },
{ "fast-vapi", 0, 0, OptionArg.STRING, ref fast_vapi_filename, "Output vapi without performing symbol resolution", null },
{ "use-fast-vapi", 0, 0, OptionArg.STRING_ARRAY, ref fast_vapis, "Use --fast-vapi output during this compile", null },
+ { "vapi-comments", 0, 0, OptionArg.NONE, ref vapi_comments, "Include comments in generated vapi", null },
{ "deps", 0, 0, OptionArg.STRING, ref dependencies, "Write make-style dependency information to this file", null },
{ "symbols", 0, 0, OptionArg.FILENAME, ref symbols_filename, "Output symbols file", "FILE" },
{ "compile", 'c', 0, OptionArg.NONE, ref compile_only, "Compile but do not link", null },
context.directory = context.basedir;
}
context.vapi_directories = vapi_directories;
+ context.vapi_comments = vapi_comments;
context.gir_directories = gir_directories;
context.metadata_directories = metadata_directories;
context.debug = debug;
*
* Copyright (C) 2006-2014 Jürg Billeter
* Copyright (C) 2006-2008 Raffaele Sandrini
+ * Copyright (C) 2014 Richard Wiedenhöft
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
return;
}
+ var comments = ns.get_comments ();
+ if (context.vapi_comments && comments.size > 0) {
+ bool first = true;
+ SourceReference? first_reference = null;
+ foreach (Comment comment in comments) {
+ if (comment.source_reference.file.file_type == SourceFileType.SOURCE) {
+ if (first) {
+ write_comment (comment);
+ first = false;
+ first_reference = comment.source_reference;
+ } else {
+ Report.warning (comment.source_reference, "Comment describes namespace, that was already described by another comment.");
+ Report.notice (first_reference, "Previous comment was here.");
+ }
+ }
+ }
+ }
+
write_attributes (ns);
write_indent ();
return;
}
+ if (context.vapi_comments && cl.comment != null) {
+ write_comment (cl.comment);
+ }
+
write_attributes (cl);
write_indent ();
return;
}
+ if (context.vapi_comments && st.comment != null) {
+ write_comment (st.comment);
+ }
+
write_attributes (st);
write_indent ();
return;
}
+ if (context.vapi_comments && iface.comment != null) {
+ write_comment (iface.comment);
+ }
+
write_attributes (iface);
write_indent ();
return;
}
+ if (context.vapi_comments && en.comment != null) {
+ write_comment (en.comment);
+ }
+
write_attributes (en);
write_indent ();
write_newline ();
}
+ if (context.vapi_comments && ev.comment != null) {
+ write_comment (ev.comment);
+ }
+
write_attributes (ev);
write_indent ();
return;
}
+ if (context.vapi_comments && edomain.comment != null) {
+ write_comment (edomain.comment);
+ }
+
write_attributes (edomain);
write_indent ();
write_newline ();
}
+ if (context.vapi_comments && ecode.comment != null) {
+ write_comment (ecode.comment);
+ }
+
write_attributes (ecode);
write_indent ();
return;
}
+ if (context.vapi_comments && c.comment != null) {
+ write_comment (c.comment);
+ }
+
write_attributes (c);
write_indent ();
return;
}
+ if (context.vapi_comments && f.comment != null) {
+ write_comment (f.comment);
+ }
+
write_attributes (f);
write_indent ();
return;
}
+ if (context.vapi_comments && cb.comment != null) {
+ write_comment (cb.comment);
+ }
+
write_attributes (cb);
write_indent ();
return;
}
+ if (context.vapi_comments && c.comment != null) {
+ write_comment (c.comment);
+ }
+
write_indent ();
write_string ("construct");
write_code_block (c.body);
}
}
+ if (context.vapi_comments && m.comment != null) {
+ write_comment (m.comment);
+ }
+
write_attributes (m);
write_indent ();
return;
}
+ if (context.vapi_comments && prop.comment != null) {
+ write_comment (prop.comment);
+ }
+
write_attributes (prop);
write_indent ();
return;
}
+ if (context.vapi_comments && sig.comment != null) {
+ write_comment (sig.comment);
+ }
+
write_attributes (sig);
write_indent ();
bol = false;
}
+
+ private void write_comment (Comment comment) {
+ Regex fix_indent_regex;
+ try {
+ fix_indent_regex = new Regex ("\\n[\\t ]*");
+ } catch (Error e) {
+ assert_not_reached ();
+ }
+
+ string replacement = "\n" + string.nfill (indent, '\t') + " ";
+ string fixed_content;
+ try {
+ fixed_content = fix_indent_regex.replace (comment.content, comment.content.length, 0, replacement);
+ } catch (Error e) {
+ assert_not_reached();
+ }
+
+ write_indent ();
+ write_string ("/*");
+ write_string (fixed_content);
+ write_string ("*/");
+ }
private void write_identifier (string s) {
char* id = (char*)s;