Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OUT / INOUT arguments in vfuncs not typed as pointers #45

Open
BlobCodes opened this issue Jun 22, 2022 · 0 comments
Open

OUT / INOUT arguments in vfuncs not typed as pointers #45

BlobCodes opened this issue Jun 22, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@BlobCodes
Copy link
Contributor

Example definition of Gtk::Widget._register_unsafe_do_measure

    private macro _register_unsafe_do_measure
      private def self._vfunc_unsafe_measure(%this : Pointer(Void), lib_orientation :  UInt32, lib_for_size :  Int32, lib_minimum :  Int32, lib_natural :  Int32, lib_minimum_baseline :  Int32, lib_natural_baseline :  Int32, ) : Void
# @orientation: 
# @for_size: 
# @minimum: (out) (transfer full) (optional) 
# @natural: (out) (transfer full) (optional) 
# @minimum_baseline: (out) (transfer full) (optional) 
# @natural_baseline: (out) (transfer full) (optional) 

        %gc_collected = !LibGObject.g_object_get_qdata(%this, GICrystal::GC_COLLECTED_QDATA_KEY).null?
        %instance = LibGObject.g_object_get_qdata(%this, GICrystal::INSTANCE_QDATA_KEY)
        raise GICrystal::ObjectCollectedError.new if %gc_collected || %instance.null?

        %instance.as(self).unsafe_do_measure(lib_orientation, lib_for_size, lib_minimum, lib_natural, lib_minimum_baseline, lib_natural_baseline)
      end

      def self._class_init(type_struct : Pointer(LibGObject::TypeClass), user_data : Pointer(Void)) : Nil
        vfunc_ptr = (type_struct.as(Pointer(Void)) + 232).as(Pointer(Pointer(Void)))
        vfunc_ptr.value = (->_vfunc_unsafe_measure(Pointer(Void), UInt32, Int32, Int32, Int32, Int32, Int32)).pointer
        previous_def
      end
    end

The last four arguments have to be pointers because their ArgInfo#direction are OUT. This is currently not accounted for.

@hugopl hugopl added the bug Something isn't working label Jun 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants