Re: Subclassing a GObject in Typescript



For methods added by Gjs, like GObject.registerClass, I'd put them into the `patch` map at the end of `main.ts`, where now are substituted lines and comments for clashing and overriden definitions. Basically what you suggest, but keys are more specific like "library.class.method". Or you can add another map if turns out really more convenient.

Then look into the `exportObjectInternal` method, which generates definitions for a given introspected class. Search for `connect` there, and def.push `registerClass` and your other definitions similarly if `cls._fullSymName` equals to "GObject.Object" or the other class you need.

For imports.package, imports.system etc you'd need to look through the `exportGjs` method in `main.ts` and hardcode a few new exports with method signatures.


On 2018-11-14 15:14, Tony Houghton wrote:
On Tue, 13 Nov 2018 at 16:01, <makepost firemail cc> wrote:

Please consider sending a pull request to ts-for-gjs with
definitions
and tests for registerClass, if you have time before I can write
them.
It's a relatively new thing, haven't needed it yet. So far the focus
has
been on GObject introspection. Definitions for other built-ins, such
as
package, signals and system, would be helpful too.

I would quite like to try this after all, but I'm not sure of the best
way to do it. I don't really like the idea of hard-wiring just the
bits I'm interested in, it would be better to add some sort of
reusable overrides system. But I think it would be OK to keep it very
simple, basically a map keyed by module name with the values
consisting of a string of extra lines of code to add to the .d.ts. Or
would you prefer something more sophisticated such as separate lists
for functions, symbols etc?

--

TH


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]