if (sym is ObjectTypeSymbol) {
var csuffix = Symbol.camel_case_to_lower_case (sym.name);
+ // FIXME Code duplication with GirParser.Node.get_default_lower_case_suffix()
// remove underscores in some cases to avoid conflicts of type macros
if (csuffix.has_prefix ("type_")) {
csuffix = "type" + csuffix.substring ("type_".length);
gir/parameter-array-length-type.test \
gir/parameter-nullable-out-simple-type.test \
gir/property-non-readable.test \
+ gir/symbol-type-csuffix.test \
annotations/deprecated.vala \
annotations/description.vala \
annotations/noaccessormethod.test \
--- /dev/null
+GIR
+
+Input:
+
+<class name="TypeFoo" c:type="TestTypeFoo" glib:type-name="TestTypeFoo" glib:get-type="test_foo_get_type" glib:type-struct="TypeFooClass" parent="GObject.Object">
+ <constructor name="new" c:identifier="test_type_foo_new">
+ <return-value transfer-ownership="full">
+ <type name="Test.TypeFoo" c:type="TestTypeFoo*"/>
+ </return-value>
+ </constructor>
+ <method name="bar" c:identifier="test_type_foo_bar">
+ <return-value transfer-ownership="none">
+ <type name="none"/>
+ </return-value>
+ </method>
+</class>
+
+Output:
+
+[CCode (cheader_filename = "test.h", type_id = "test_foo_get_type ()")]
+public class TypeFoo : GLib.Object {
+ [CCode (cname = "test_type_foo_new", has_construct_function = false)]
+ public TypeFoo ();
+ [CCode (cname = "test_type_foo_bar")]
+ public void bar ();
+}
FINISH_VFUNC_NAME,
NO_ACCESSOR_METHOD,
CNAME,
- DELEGATE_TARGET;
+ DELEGATE_TARGET,
+ LOWER_CASE_CSUFFIX;
public static ArgumentType? from_string (string name) {
var enum_class = (EnumClass) typeof(ArgumentType).class_ref ();
public string get_lower_case_csuffix () {
var suffix = symbol.get_attribute_string ("CCode", "lower_case_csuffix");
+ if (metadata.has_argument (ArgumentType.LOWER_CASE_CSUFFIX)) {
+ suffix = metadata.get_string (ArgumentType.LOWER_CASE_CSUFFIX);
+ }
// we can't rely on gir suffix if metadata changed the name
if (suffix == null && girdata != null && girdata["c:symbol-prefix"] != null && !metadata.has_argument (ArgumentType.NAME)) {
}
public string get_default_lower_case_csuffix () {
- return Symbol.camel_case_to_lower_case (name);
+ var csuffix = Symbol.camel_case_to_lower_case (name);
+
+ // FIXME Code duplication with CCodeAttribute.get_default_lower_case_suffix()
+ // remove underscores in some cases to avoid conflicts of type macros
+ if (csuffix.has_prefix ("type_")) {
+ csuffix = "type" + csuffix.substring ("type_".length);
+ } else if (csuffix.has_prefix ("is_")) {
+ csuffix = "is" + csuffix.substring ("is_".length);
+ }
+ if (csuffix.has_suffix ("_class")) {
+ csuffix = csuffix.substring (0, csuffix.length - "_class".length) + "class";
+ }
+ return csuffix;
}
public string get_cprefix () {