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

glib: metadata for GObject Introspection isn't used #167524

Closed
4 tasks done
tatethurston opened this issue Mar 29, 2024 · 6 comments
Closed
4 tasks done

glib: metadata for GObject Introspection isn't used #167524

tatethurston opened this issue Mar 29, 2024 · 6 comments
Labels
outdated PR was locked due to age upstream issue An upstream issue report is needed

Comments

@tatethurston
Copy link

brew gist-logs <formula> link OR brew config AND brew doctor output

brew gist-logs glib
Error: No logs.

Verification

What were you trying to do (and why)?

Run the example project for https://github.com/ruby-gnome/ruby-gnome.

What happened (include all command output)?

$(brew --prefix)/share/gir-1.0/Gio-2.0.gir has the following content. introspectable="0" is the important part. It seems that metadata for GObject Introspection isn't used. It should be extracted from https://gitlab.gnome.org/GNOME/glib/-/blob/main/gio/gcontenttype.c?ref_type=heads#L936-945 .

    <function name="content_types_get_registered"
              c:identifier="g_content_types_get_registered"
              introspectable="0">
      <source-position filename="gio/gcontenttype.h" line="72"/>
      <return-value>
        <type name="GLib.List" c:type="GList*">
          <type name="gpointer" c:type="gpointer"/>
        </type>
      </return-value>
    </function>

What did you expect to happen?

See above. Cross posting from ruby-gnome/ruby-gnome#1610 (comment).

Step-by-step reproduction instructions (by running brew commands)

`$(brew --prefix)/share/gir-1.0/Gio-2.0.gir`
@tatethurston
Copy link
Author

Still spinning up on the details here, opened an issue to kick off a conversation per ruby-gnome/ruby-gnome#1610. cc @kou

@Bo98
Copy link
Member

Bo98 commented Mar 29, 2024

That's probably because gcontentype.c is not used on macOS - gosxcontentype.m is used instead.

Prior to gobject-introspection 1.80, this mega comment file was used instead: https://gitlab.gnome.org/GNOME/gobject-introspection/-/blob/1.78.1/gir/gio-2.0.c?ref_type=tags#L14992.

Now that the actual source files are used, gcontenttype.c comments are never read. This seems like something to ask upstream if it is intentional.

Though it's also worth noting g_content_types_get_registered will always return NULL on macOS

@tatethurston
Copy link
Author

Ah -- yes reverting to gobject-introspection v1.78 "resolves" the linked issue.

@kou
Copy link
Contributor

kou commented Apr 2, 2024

Wow. Thanks for investing this.

@tatethurston Could you report this to upstream? https://gitlab.gnome.org/GNOME/glib/
g_content_types_get_registered()'s metadata for GObject Introspection is missing because gosxcontentype.m doesn't have a comment for GObject Introspection.

This may work:

diff --git a/gio/gcontenttype-win32.c b/gio/gcontenttype-win32.c
index 11ea203ab..5e454785b 100644
--- a/gio/gcontenttype-win32.c
+++ b/gio/gcontenttype-win32.c
@@ -400,6 +400,16 @@ g_content_type_guess (const gchar  *filename,
   return g_strdup ("*");
 }
 
+/**
+ * g_content_types_get_registered:
+ *
+ * Gets a list of strings containing all the registered content types
+ * known to the system. The list and its data should be freed using
+ * `g_list_free_full (list, g_free)`.
+ *
+ * Returns: (element-type utf8) (transfer full): list of the registered
+ *     content types
+ */
 GList *
 g_content_types_get_registered (void)
 {
diff --git a/gio/gosxcontenttype.m b/gio/gosxcontenttype.m
index 4d7a650c7..9bbca9aba 100644
--- a/gio/gosxcontenttype.m
+++ b/gio/gosxcontenttype.m
@@ -594,6 +594,16 @@ g_content_type_guess (const gchar  *filename,
   return create_cstr_from_cfstring (uti);
 }
 
+/**
+ * g_content_types_get_registered:
+ *
+ * Gets a list of strings containing all the registered content types
+ * known to the system. The list and its data should be freed using
+ * `g_list_free_full (list, g_free)`.
+ *
+ * Returns: (element-type utf8) (transfer full): list of the registered
+ *     content types
+ */
 GList *
 g_content_types_get_registered (void)
 {
diff --git a/gio/meson.build b/gio/meson.build
index 59c2b0fc0..7f4cda2ac 100644
--- a/gio/meson.build
+++ b/gio/meson.build
@@ -605,6 +605,7 @@ gio_base_sources = files(
   'glistmodel.c',
   'gliststore.c',
 )
+gio_base_sources += contenttype_sources
 
 gio_sources = gio_base_sources
 
@@ -612,7 +613,6 @@ if glib_build_shared
   gio_sources += files ('../glib/gtrace.c')
 endif
 
-gio_sources += contenttype_sources
 gio_sources += gdbus_daemon_sources
 gio_sources += unix_sources
 gio_sources += win32_sources

@cho-m cho-m removed the bug Reproducible Homebrew/homebrew-core bug label Apr 3, 2024
@tatethurston
Copy link
Author

Wow. Thanks for investing this.

@tatethurston Could you report this to upstream? https://gitlab.gnome.org/GNOME/glib/ g_content_types_get_registered()'s metadata for GObject Introspection is missing because gosxcontentype.m doesn't have a comment for GObject Introspection.

This may work:

diff --git a/gio/gcontenttype-win32.c b/gio/gcontenttype-win32.c
index 11ea203ab..5e454785b 100644
--- a/gio/gcontenttype-win32.c
+++ b/gio/gcontenttype-win32.c
@@ -400,6 +400,16 @@ g_content_type_guess (const gchar  *filename,
   return g_strdup ("*");
 }
 
+/**
+ * g_content_types_get_registered:
+ *
+ * Gets a list of strings containing all the registered content types
+ * known to the system. The list and its data should be freed using
+ * `g_list_free_full (list, g_free)`.
+ *
+ * Returns: (element-type utf8) (transfer full): list of the registered
+ *     content types
+ */
 GList *
 g_content_types_get_registered (void)
 {
diff --git a/gio/gosxcontenttype.m b/gio/gosxcontenttype.m
index 4d7a650c7..9bbca9aba 100644
--- a/gio/gosxcontenttype.m
+++ b/gio/gosxcontenttype.m
@@ -594,6 +594,16 @@ g_content_type_guess (const gchar  *filename,
   return create_cstr_from_cfstring (uti);
 }
 
+/**
+ * g_content_types_get_registered:
+ *
+ * Gets a list of strings containing all the registered content types
+ * known to the system. The list and its data should be freed using
+ * `g_list_free_full (list, g_free)`.
+ *
+ * Returns: (element-type utf8) (transfer full): list of the registered
+ *     content types
+ */
 GList *
 g_content_types_get_registered (void)
 {
diff --git a/gio/meson.build b/gio/meson.build
index 59c2b0fc0..7f4cda2ac 100644
--- a/gio/meson.build
+++ b/gio/meson.build
@@ -605,6 +605,7 @@ gio_base_sources = files(
   'glistmodel.c',
   'gliststore.c',
 )
+gio_base_sources += contenttype_sources
 
 gio_sources = gio_base_sources
 
@@ -612,7 +613,6 @@ if glib_build_shared
   gio_sources += files ('../glib/gtrace.c')
 endif
 
-gio_sources += contenttype_sources
 gio_sources += gdbus_daemon_sources
 gio_sources += unix_sources
 gio_sources += win32_sources

https://gitlab.gnome.org/GNOME/glib/-/issues/3322

@kou
Copy link
Contributor

kou commented Apr 5, 2024

Thanks.
I think that we can close this as an upstream issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated PR was locked due to age upstream issue An upstream issue report is needed
Projects
None yet
Development

No branches or pull requests

4 participants