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

Implement basic vfunc support #1319

Closed
6 tasks done
bilelmoussaoui opened this issue Feb 20, 2022 · 9 comments
Closed
6 tasks done

Implement basic vfunc support #1319

bilelmoussaoui opened this issue Feb 20, 2022 · 9 comments

Comments

@bilelmoussaoui
Copy link
Member

bilelmoussaoui commented Feb 20, 2022

Currently, the parsing part ignores the virtual functions definitions. Ideally we would need:

  • Parse the XML for all the various vfuncs

  • Have a [object.subclass] configuration that would allow you to

    • Modify the subclassing trait, e.g it would be by default called TypeImpl & TypeImplExt for chaining up
    • Modify the [object.subclass.vfunc] by marking at either ignore = true or rename = "some_different_vfunc_name"
    • In a far feature, configure the vfuncs once we can auto generate them
  • Embed the docs for the TypeImpl::some_vfunc from the corresponding TypeClass::some_vfunc

  • Generate working docs links for the vfuncs

@bilelmoussaoui bilelmoussaoui changed the title Implement basic vfunc parsing Implement basic vfunc support Feb 20, 2022
@hohilwik
Copy link

hohilwik commented Apr 1, 2022

Hi, I would like to work on this. It would take me at least a week to go through the codebase before I can start contributing though, is that okay?

@bilelmoussaoui
Copy link
Member Author

Sure, make sure to check #604 for inspiration as well.

@hohilwik
Copy link

Could you give me some examples of the kinds of parsing for virtual-method parser.rs needs to support? I am not entirely sure of the inputs

@bilelmoussaoui
Copy link
Member Author

For example

      <virtual-method name="get_action_name" invoker="get_action_name">
        <attribute name="org.gtk.Property.get" value="action-name"/>
        <doc xml:space="preserve">Gets the action name for @actionable.</doc>
        <return-value transfer-ownership="none" nullable="1">
          <doc xml:space="preserve">the action name</doc>
          <type name="utf8" c:type="const char*"/>
        </return-value>
        <parameters>
          <instance-parameter name="actionable" transfer-ownership="none">
            <doc xml:space="preserve">a `GtkActionable` widget</doc>
            <type name="Actionable" c:type="GtkActionable*"/>
          </instance-parameter>
        </parameters>
      </virtual-method>

Look at the files in the gir-files repository.

@hohilwik
Copy link

Thank you. I will try to get the first task done by 16th

@hohilwik
Copy link

Hello, I have slowly realized that this issue would require hundreds of lines of code so, if possible could you give me some guidance on the ways you want all this implemented? I am not very familiar with the codebase so don't know how gobject and gir internals work.

There was an old commit from vhdirk reviewed by @sdroege which did a few things with regards to vfunc parsing, but the review said that it still had a lot of assumptions about crate name, return value, etc. Some info on the shortcomings in that commit would help a lot, and if there is some doc on the expected behavior of vfuncs, that would help too

@hohilwik
Copy link

Hi, so far I have understood that just the virtual-method parsing (line 606 to 610 in https://github.com/gtk-rs/gir/pull/604/files) and read_virtual_method function(line 1017 to 1091) with some modification to include annotations for parameters and return values is what is required.

Is that correct?

@bilelmoussaoui
Copy link
Member Author

bilelmoussaoui commented Apr 21, 2022

The whole subclassing code (which uses virtual functions that you have to implement to change a behaviour) is all manual for now but we want to change that somehow. The goal of this issue is to start by doing the parsing of virtual-functions from the GIR file and include that information in Class/Interface types so we can use them for generating the documentation.

Instead of trying to do everything at once, I would suggest doing multiple smaller PRs that follows more or less what I mentioned in the issue and allows ticking those items.

@bilelmoussaoui
Copy link
Member Author

I believe the scope of the issue is now implemented. An issue to discuss generating subclassing code could be opened if someone want to work on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants