}
public CCodeExpression? get_destroy_func_expression (DataType type) {
- if (type.data_type == glist_type || type.data_type == gslist_type) {
+ if (context.profile == Profile.GOBJECT && (type.data_type == glist_type || type.data_type == gslist_type)) {
// create wrapper function to free list elements if necessary
bool elements_require_free = false;
// normal value type, no null check
ccall.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, cvar));
- if (type.data_type == gvalue_type) {
+ if (gvalue_type != null && type.data_type == gvalue_type) {
// g_value_unset must not be called for already unset values
var cisvalid = new CCodeFunctionCall (new CCodeIdentifier ("G_IS_VALUE"));
cisvalid.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, cvar));
/* set freed references to NULL to prevent further use */
var ccomma = new CCodeCommaExpression ();
- if (type.data_type == gstringbuilder_type
- || type.data_type == garray_type
- || type.data_type == gbytearray_type
- || type.data_type == gptrarray_type) {
+ if (context.profile == Profile.GOBJECT
+ && (type.data_type == gstringbuilder_type
+ || type.data_type == garray_type
+ || type.data_type == gbytearray_type
+ || type.data_type == gptrarray_type)) {
ccall.add_argument (new CCodeConstant ("TRUE"));
} else if (type is ArrayType) {
var array_type = (ArrayType) type;
ccomma.append_expression (copy_call);
ccomma.append_expression (ctemp);
- if (expression_type.data_type == gvalue_type) {
+ if (gvalue_type != null && expression_type.data_type == gvalue_type) {
// g_value_init/copy must not be called for uninitialized values
var cisvalid = new CCodeFunctionCall (new CCodeIdentifier ("G_IS_VALUE"));
cisvalid.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, cexpr));
}
public override void visit_cast_expression (CastExpression expr) {
- if (expr.inner.value_type != null && expr.inner.value_type.data_type == gvalue_type
+ if (expr.inner.value_type != null && gvalue_type != null && expr.inner.value_type.data_type == gvalue_type
&& expr.type_reference.get_type_id () != null) {
// explicit conversion from GValue
var ccall = new CCodeFunctionCall (new CCodeIdentifier (expr.type_reference.data_type.get_get_value_function ()));
var cl = expr.type_reference.data_type as Class;
var iface = expr.type_reference.data_type as Interface;
- if (iface != null || (cl != null && !cl.is_compact)) {
+ if (context.profile == Profile.GOBJECT && (iface != null || (cl != null && !cl.is_compact))) {
// checked cast for strict subtypes of GTypeInstance
if (expr.is_silent_cast) {
var ccomma = new CCodeCommaExpression ();
bool unboxing = (expression_type is ValueType && expression_type.nullable
&& target_type is ValueType && !target_type.nullable);
- bool gvalue_boxing = (target_type != null
+ bool gvalue_boxing = (context.profile == Profile.GOBJECT
+ && target_type != null
&& target_type.data_type == gvalue_type
&& !(expression_type is NullType)
&& expression_type.get_type_id () != "G_TYPE_VALUE");
}
if (m is CreationMethod) {
- ccall.add_argument (new CCodeIdentifier ("object_type"));
+ if (context.profile == Profile.GOBJECT) {
+ ccall.add_argument (new CCodeIdentifier ("object_type"));
+ } else {
+ ccall.add_argument (new CCodeIdentifier ("self"));
+ }
foreach (DataType base_type in current_class.get_base_types ()) {
if (base_type.data_type is Class) {
param.accept (codegen);
}
head.generate_dynamic_method_wrapper ((DynamicMethod) m);
- } else if (m is CreationMethod) {
+ } else if (m is CreationMethod && context.profile == Profile.GOBJECT) {
ccall_expr = new CCodeAssignment (new CCodeIdentifier ("self"), new CCodeCastExpression (ccall, current_class.get_cname () + "*"));
}
return;
}
- if (st.has_type_id) {
- decl_space.add_type_declaration (new CCodeNewline ());
- var macro = "(%s_get_type ())".printf (st.get_lower_case_cname (null));
- decl_space.add_type_declaration (new CCodeMacroReplacement (st.get_type_id (), macro));
-
- var type_fun = new StructRegisterFunction (st, context);
- type_fun.init_from_type (false);
- decl_space.add_type_member_declaration (type_fun.get_declaration ());
+ if (context.profile == Profile.GOBJECT) {
+ if (st.has_type_id) {
+ decl_space.add_type_declaration (new CCodeNewline ());
+ var macro = "(%s_get_type ())".printf (st.get_lower_case_cname (null));
+ decl_space.add_type_declaration (new CCodeMacroReplacement (st.get_type_id (), macro));
+
+ var type_fun = new StructRegisterFunction (st, context);
+ type_fun.init_from_type (false);
+ decl_space.add_type_member_declaration (type_fun.get_declaration ());
+ }
}
var instance_struct = new CCodeStruct ("_%s".printf (st.get_cname ()));
st.accept_children (codegen);
- if (!st.is_boolean_type () && !st.is_integer_type () && !st.is_floating_type ()) {
+ if (context.profile == Profile.GOBJECT && !st.is_boolean_type () && !st.is_integer_type () && !st.is_floating_type ()) {
if (st.is_disposable ()) {
add_struct_copy_function (st);
add_struct_destroy_function (st);