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

libgee-0.8: undefined constant LibGee::FutureMapFunc #32

Open
aljelly opened this issue Dec 31, 2019 · 2 comments
Open

libgee-0.8: undefined constant LibGee::FutureMapFunc #32

aljelly opened this issue Dec 31, 2019 · 2 comments
Labels
help wanted incomplete-gir Weirdness caused by wrong or missing GIR data

Comments

@aljelly
Copy link
Contributor

aljelly commented Dec 31, 2019

After the fix for #31, I tried building libgee again in the same way:

require_gobject("Gee")

Results in:

There was a problem expanding macro 'require_gobject'

Code in src/gtk-test.cr:5:1

 5 | require_gobject("Gee")
     ^
Called macro defined in lib/gobject/src/gobject.cr:7:1

 7 | macro require_gobject(namespace)

Which expanded to:

 > 899 | fun future_wait_async = gee_future_wait_async(this : Future*, _callback : LibGio::AsyncReadyCallback, _callback__target : Void*) : Void
 > 900 | fun future_wait_finish = gee_future_wait_finish(this : Future*, _res : LibGio::AsyncResult*, error : LibGLib::Error**) : Void*
 > 901 | fun future_map = gee_future_map(this : Future*, a_type : UInt64, a_dup_func : LibGObject::BoxedCopyFunc, a_destroy_func : LibGLib::DestroyNotify, func : LibGee::FutureMapFunc, func_target : Void*, func_target_destroy_notify : LibGLib::DestroyNotify) : LibGee::Future*
                                                                                                                                                                  ^--------------------
Error: undefined constant LibGee::FutureMapFunc

Context (from error trace):

 >  867 |   struct Future # interface
 >  868 |     parent_iface : LibGObject::TypeInterface
 >  869 |     wait : -> Void
 >  870 |     wait_until : -> Void
 >  871 |     wait_async : -> Void
 >  872 |     wait_finish : -> Void
 >  873 |     map : -> Void
 >  874 |     light_map : -> Void
 >  875 |     light_map_broken : -> Void
 >  876 |     zip : -> Void
 >  877 |     flat_map : -> Void
 >  878 |     get_value : -> Void
 >  879 |     get_ready : -> Void
 >  880 |     get_exception : -> Void
 >  881 |   # Requires Object
 >  882 |     # Virtual function wait
 >  883 |     # Virtual function wait_until
 >  884 |     # Virtual function wait_async
 >  885 |     # Virtual function wait_finish
 >  886 |     # Virtual function map
 >  887 |     # Virtual function light_map
 >  888 |     # Virtual function light_map_broken
 >  889 |     # Virtual function zip
 >  890 |     # Virtual function flat_map
 >  891 |     # Virtual function get_value
 >  892 |     # Virtual function get_ready
 >  893 |     # Virtual function get_exception
 >  894 |     # Property ready : Bool
 >  895 |     # Property exception : LibGLib::Error**
 >  896 |   end
 >  897 |   fun future_wait = gee_future_wait(this : Future*, error : LibGLib::Error**) : Void*
 >  898 |   fun future_wait_until = gee_future_wait_until(this : Future*, end_time : Int64, value : Void**, error : LibGLib::Error**) : Bool
 >  899 |   fun future_wait_async = gee_future_wait_async(this : Future*, _callback : LibGio::AsyncReadyCallback, _callback__target : Void*) : Void
 >  900 |   fun future_wait_finish = gee_future_wait_finish(this : Future*, _res : LibGio::AsyncResult*, error : LibGLib::Error**) : Void*
 >  901 |   # line causing error below
 >  901 |   fun future_map = gee_future_map(this : Future*, a_type : UInt64, a_dup_func : LibGObject::BoxedCopyFunc, a_destroy_func : LibGLib::DestroyNotify, func : LibGee::FutureMapFunc, func_target : Void*, func_target_destroy_notify : LibGLib::DestroyNotify) : LibGee::Future*
 >  902 |   fun future_light_map = gee_future_light_map_fixed(this : Future*, a_type : UInt64, a_dup_func : LibGObject::BoxedCopyFunc, a_destroy_func : LibGLib::DestroyNotify, func : LibGee::FutureLightMapFunc, func_target : Void*, func_target_destroy_notify : LibGLib::DestroyNotify) : LibGee::Future*
 >  903 |   fun future_light_map_broken = gee_future_light_map(this : Future*, a_type : UInt64, a_dup_func : LibGObject::BoxedCopyFunc, a_destroy_func : LibGLib::DestroyNotify, func : LibGee::FutureLightMapFunc, func_target : Void*) : LibGee::Future*
 >  904 |   fun future_zip = gee_future_zip(this : Future*, a_type : UInt64, a_dup_func : LibGObject::BoxedCopyFunc, a_destroy_func : LibGLib::DestroyNotify, b_type : UInt64, b_dup_func : LibGObject::BoxedCopyFunc, b_destroy_func : LibGLib::DestroyNotify, zip_func : LibGee::FutureZipFunc, zip_func_target : Void*, second : LibGee::Future*) : LibGee::Future*
 >  905 |   fun future_flat_map = gee_future_flat_map(this : Future*, a_type : UInt64, a_dup_func : LibGObject::BoxedCopyFunc, a_destroy_func : LibGLib::DestroyNotify, func : LibGee::FutureFlatMapFunc, func_target : Void*, func_target_destroy_notify : LibGLib::DestroyNotify) : LibGee::Future*
 >  906 |   fun future_get_value = gee_future_get_value(this : Future*) : Void*
 >  907 |   fun future_get_ready = gee_future_get_ready(this : Future*) : Bool
 >  908 |   fun future_get_exception = gee_future_get_exception(this : Future*) : LibGLib::Error**

Possibly the relevant file within Gee:

https://github.com/GNOME/libgee/blob/5e66324654b7d70d7c28793491a4edfe6d8a0d85/gee/future.vala#L132

jhass added a commit that referenced this issue Jan 6, 2020
@jhass jhass added help wanted incomplete-gir Weirdness caused by wrong or missing GIR data labels Jan 6, 2020
@jhass
Copy link
Owner

jhass commented Jan 6, 2020

So there's no info about FutureMapFunc in the GIR:

$ bin/gi-dump -n4 Gee
+ Future (interface)
...
  * methods
...
      + map (function)
...
        * args
...
            + func (arg)
              * direction = ZERO_NONE
              * optional = false
              * nullable = false
              * type
                  + <no name> (type)
                    * tag = INTERFACE
                    * pointer = false
                    * interface
                      + FutureMapFunc (unresolved)
...

From the source we can see it's a MapFunc, which we have info about in the GIR, but we could only hardcode that relationship into the generator which is... uh. I wonder how other generators solve this?

For now I updated the generator to use Void* for unresolved type references, so it should at least compile now and probably even work when you pass a MapFunc and type cast it to Void*. Well and handle all the closure data fun.

@aljelly
Copy link
Contributor Author

aljelly commented Jan 20, 2020

It's building now, thanks. I'll leave this issue open as the case should probably be correctly handled as you said.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted incomplete-gir Weirdness caused by wrong or missing GIR data
Projects
None yet
Development

No branches or pull requests

2 participants