* @param text the comment text
*/
public void write_comment (string text) {
- write_indent ();
- stream.puts ("/*");
- bool first = true;
-
- /* separate declaration due to missing memory management in foreach statements */
- var lines = text.split ("\n");
+ try {
+ write_indent ();
+ stream.puts ("/*");
+ bool first = true;
+
+ // discard tabs at beginning of line
+ var regex = new GLib.Regex ("^\t+");
+
+ /* separate declaration due to missing memory management in foreach statements */
+ var lines = text.split ("\n");
- foreach (string line in lines) {
- if (!first) {
- write_indent ();
- } else {
- first = false;
- }
+ foreach (string line in lines) {
+ if (!first) {
+ write_indent ();
+ } else {
+ first = false;
+ }
- var lineparts = line.split ("*/");
+ var lineparts = regex.replace_literal (line, -1, 0, "").split ("*/");
- for (int i = 0; lineparts[i] != null; i++) {
- stream.puts (lineparts[i]);
- if (lineparts[i+1] != null) {
- stream.puts ("* /");
+ for (int i = 0; lineparts[i] != null; i++) {
+ stream.puts (lineparts[i]);
+ if (lineparts[i+1] != null) {
+ stream.puts ("* /");
+ }
}
}
+ stream.puts ("*/");
+ write_newline ();
+ } catch (RegexError e) {
+ // ignore
}
- stream.puts ("*/");
- write_newline ();
}
}
var prop = (Property) acc.prop;
+ if (acc.comment != null) {
+ source_type_member_definition.append (new CCodeComment (acc.comment.content));
+ }
+
bool returns_real_struct = acc.readable && prop.property_type.is_real_non_null_struct_type ();
acc.accept_children (codegen);
}
}
+ if (m.comment != null) {
+ source_type_member_definition.append (new CCodeComment (m.comment.content));
+ }
+
function = new CCodeFunction (m.get_real_cname ());
m.ccodenode = function;
continue;
}
+ if (prop.comment != null) {
+ init_block.add_statement (new CCodeComment (prop.comment.content));
+ }
+
if (prop.overrides || prop.base_interface_property != null) {
var cinst = new CCodeFunctionCall (new CCodeIdentifier ("g_object_class_override_property"));
cinst.add_argument (ccall);
add_finalize_function (cl);
}
+ if (cl.comment != null) {
+ source_type_member_definition.append (new CCodeComment (cl.comment.content));
+ }
+
var type_fun = new ClassRegisterFunction (cl, context);
type_fun.init_from_type (in_plugin);
source_declarations.add_type_member_declaration (type_fun.get_source_declaration ());
if (!cl.is_compact) {
/* create signals */
foreach (Signal sig in cl.get_signals ()) {
+ if (sig.comment != null) {
+ init_block.add_statement (new CCodeComment (sig.comment.content));
+ }
init_block.add_statement (new CCodeExpressionStatement (head.get_signal_creation (sig, cl)));
}
}
add_interface_base_init_function (iface);
+ if (iface.comment != null) {
+ source_type_member_definition.append (new CCodeComment (iface.comment.content));
+ }
+
var type_fun = create_interface_register_function (iface);
type_fun.init_from_type (in_plugin);
source_declarations.add_type_member_declaration (type_fun.get_source_declaration ());
continue;
}
+ if (prop.comment != null) {
+ init_block.add_statement (new CCodeComment (prop.comment.content));
+ }
+
var cinst = new CCodeFunctionCall (new CCodeIdentifier ("g_object_interface_install_property"));
cinst.add_argument (new CCodeIdentifier ("iface"));
cinst.add_argument (head.get_param_spec (prop));
/* create signals */
foreach (Signal sig in iface.get_signals ()) {
+ if (sig.comment != null) {
+ init_block.add_statement (new CCodeComment (sig.comment.content));
+ }
init_block.add_statement (new CCodeExpressionStatement (head.get_signal_creation (sig, iface)));
}
prop.initializer = parse_expression ();
expect (TokenType.SEMICOLON);
} else {
+ comment = scanner.pop_comment ();
+
var accessor_begin = get_location ();
var accessor_attrs = parse_attributes ();
var accessor_access = parse_access_modifier (SymbolAccessibility.PUBLIC);
block = parse_block ();
prop.external = false;
}
- prop.get_accessor = new PropertyAccessor (true, false, false, value_type, block, get_src (accessor_begin));
+ prop.get_accessor = new PropertyAccessor (true, false, false, value_type, block, get_src (accessor_begin), comment);
set_attributes (prop.get_accessor, accessor_attrs);
prop.get_accessor.access = accessor_access;
} else {
block = parse_block ();
prop.external = false;
}
- prop.set_accessor = new PropertyAccessor (false, writable, _construct, value_type, block, get_src (accessor_begin));
+ prop.set_accessor = new PropertyAccessor (false, writable, _construct, value_type, block, get_src (accessor_begin), comment);
set_attributes (prop.set_accessor, accessor_attrs);
prop.set_accessor.access = accessor_access;
}
* @param source reference to source code
* @return newly created property accessor
*/
- public PropertyAccessor (bool readable, bool writable, bool construction, DataType? value_type, Block? body, SourceReference? source_reference) {
- base (null, source_reference);
+ public PropertyAccessor (bool readable, bool writable, bool construction, DataType? value_type, Block? body, SourceReference? source_reference, Comment? comment = null) {
+ base (null, source_reference, comment);
this.readable = readable;
this.writable = writable;
this.construction = construction;
void push_comment (string comment_item, SourceReference source_reference, bool file_comment) {
if (comment_item[0] == '*') {
+ if (_comment != null) {
+ // extra doc comment, add it to source file comments
+ source_file.add_comment (_comment);
+ }
_comment = new Comment (comment_item, source_reference);
}