Lines 543-548
gjs_fill_method_instance (JSContext *context,
Link Here
|
543 |
GIBaseInfo *container = g_base_info_get_container((GIBaseInfo *) function->info); |
543 |
GIBaseInfo *container = g_base_info_get_container((GIBaseInfo *) function->info); |
544 |
GIInfoType type = g_base_info_get_type(container); |
544 |
GIInfoType type = g_base_info_get_type(container); |
545 |
GType gtype = g_registered_type_info_get_g_type ((GIRegisteredTypeInfo *)container); |
545 |
GType gtype = g_registered_type_info_get_g_type ((GIRegisteredTypeInfo *)container); |
|
|
546 |
GITransfer transfer = g_callable_info_get_instance_ownership_transfer (function->info); |
546 |
|
547 |
|
547 |
switch (type) { |
548 |
switch (type) { |
548 |
case GI_INFO_TYPE_STRUCT: |
549 |
case GI_INFO_TYPE_STRUCT: |
Lines 553-558
gjs_fill_method_instance (JSContext *context,
Link Here
|
553 |
return JS_FALSE; |
554 |
return JS_FALSE; |
554 |
|
555 |
|
555 |
out_arg->v_pointer = gjs_gerror_from_error(context, obj); |
556 |
out_arg->v_pointer = gjs_gerror_from_error(context, obj); |
|
|
557 |
if (transfer == GI_TRANSFER_EVERYTHING) |
558 |
out_arg->v_pointer = g_error_copy ((GError*) out_arg->v_pointer); |
556 |
} else { |
559 |
} else { |
557 |
if (!gjs_typecheck_boxed(context, obj, |
560 |
if (!gjs_typecheck_boxed(context, obj, |
558 |
container, gtype, |
561 |
container, gtype, |
Lines 560-565
gjs_fill_method_instance (JSContext *context,
Link Here
|
560 |
return JS_FALSE; |
563 |
return JS_FALSE; |
561 |
|
564 |
|
562 |
out_arg->v_pointer = gjs_c_struct_from_boxed(context, obj); |
565 |
out_arg->v_pointer = gjs_c_struct_from_boxed(context, obj); |
|
|
566 |
if (transfer == GI_TRANSFER_EVERYTHING) { |
567 |
if (gtype != G_TYPE_NONE) |
568 |
out_arg->v_pointer = g_boxed_copy (gtype, out_arg->v_pointer); |
569 |
else { |
570 |
gjs_throw (context, "Cannot transfer ownership of instance argument for non boxed structure"); |
571 |
return JS_FALSE; |
572 |
} |
573 |
} |
563 |
} |
574 |
} |
564 |
break; |
575 |
break; |
565 |
|
576 |
|
Lines 569-574
gjs_fill_method_instance (JSContext *context,
Link Here
|
569 |
return JS_FALSE; |
580 |
return JS_FALSE; |
570 |
|
581 |
|
571 |
out_arg->v_pointer = gjs_c_union_from_union(context, obj); |
582 |
out_arg->v_pointer = gjs_c_union_from_union(context, obj); |
|
|
583 |
if (transfer == GI_TRANSFER_EVERYTHING) |
584 |
out_arg->v_pointer = g_boxed_copy (gtype, out_arg->v_pointer); |
572 |
break; |
585 |
break; |
573 |
|
586 |
|
574 |
case GI_INFO_TYPE_OBJECT: |
587 |
case GI_INFO_TYPE_OBJECT: |
Lines 577-586
gjs_fill_method_instance (JSContext *context,
Link Here
|
577 |
if (!gjs_typecheck_object(context, obj, gtype, JS_TRUE)) |
590 |
if (!gjs_typecheck_object(context, obj, gtype, JS_TRUE)) |
578 |
return JS_FALSE; |
591 |
return JS_FALSE; |
579 |
out_arg->v_pointer = gjs_g_object_from_object(context, obj); |
592 |
out_arg->v_pointer = gjs_g_object_from_object(context, obj); |
|
|
593 |
if (transfer == GI_TRANSFER_EVERYTHING) |
594 |
g_object_ref (out_arg->v_pointer); |
580 |
} else if (gjs_typecheck_is_fundamental(context, obj, JS_FALSE)) { |
595 |
} else if (gjs_typecheck_is_fundamental(context, obj, JS_FALSE)) { |
581 |
if (!gjs_typecheck_fundamental(context, obj, gtype, JS_TRUE)) |
596 |
if (!gjs_typecheck_fundamental(context, obj, gtype, JS_TRUE)) |
582 |
return JS_FALSE; |
597 |
return JS_FALSE; |
583 |
out_arg->v_pointer = gjs_g_fundamental_from_object(context, obj); |
598 |
out_arg->v_pointer = gjs_g_fundamental_from_object(context, obj); |
|
|
599 |
if (transfer == GI_TRANSFER_EVERYTHING) |
600 |
gjs_fundamental_ref (context, out_arg->v_pointer); |
584 |
} else { |
601 |
} else { |
585 |
gjs_throw_custom(context, "TypeError", |
602 |
gjs_throw_custom(context, "TypeError", |
586 |
"%s.%s is not an object instance neither a fundamental instance of a supported type", |
603 |
"%s.%s is not an object instance neither a fundamental instance of a supported type", |
587 |
- |
|
|