}
public override void visit_error_code (ErrorCode ecode) {
+ if (ecode.get_cname () != ecode.get_default_cname ()) {
+ write_indent ();
+ write_string ("[CCode (cname = \"%s\")]".printf (ecode.get_cname ()));
+ }
write_indent ();
write_identifier (ecode.name);
write_string (",");
public override string get_cname (bool const_type = false) {
if (cname == null) {
- var edomain = (ErrorDomain) parent_symbol;
- cname = "%s%s".printf (edomain.get_cprefix (), name);
+ cname = get_default_cname ();
}
return cname;
}
+ public string get_default_cname () {
+ var edomain = (ErrorDomain) parent_symbol;
+ return "%s%s".printf (edomain.get_cprefix (), name);
+ }
+
+ public void set_cname (string value) {
+ this.cname = value;
+ }
+
public override string? get_lower_case_cname (string? infix) {
return get_cname ().down ();
}
+ private void process_ccode_attribute (Attribute a) {
+ if (a.has_argument ("cname")) {
+ cname = a.get_string ("cname");
+ }
+ }
+
+ /**
+ * Process all associated attributes.
+ */
+ public void process_attributes () {
+ foreach (Attribute a in attributes) {
+ if (a.name == "CCode") {
+ process_ccode_attribute (a);
+ }
+ }
+ }
+
public override bool check (CodeContext context) {
if (checked) {
return !error;
checked = true;
+ process_attributes ();
+
if (value != null) {
value.check (context);
}