Skip to content

GLib.HashTable parameters are incorrect #392

@ptomato

Description

@ptomato

Description

Functions that accept or return a GHashTable have those parameters exposed as plain objects in GJS. Only string (utf8, filename) and integer (bool, 8-32 bit ints) keys are supported. gunichar can be passed as string or integer. Other types will throw during marshalling.

The current type definitions have these parameters as GLib.HashTable<K, V> but I don't believe there's currently any way to actually get a GLib.HashTable object in GJS.

Current vs Expected Behavior

Current:

// Current behavior/type definition
// return value in GLib.Uri:
static parse_params(params: string, length: bigint | number, separators: string, flags: UriParamsFlags): HashTable<string, string>;

// in-argument in GLib.HashTable:
static size(hash_table: { [key: string]: any } | HashTable<never, never>): number;

Expected:

// Expected behavior/type definition
// in GLib.Uri:
static parse_params(params: string, length: bigint | number, separators: string, flags: UriParamsFlags): { [key: string]: string; };
// in GLib.HashTable:
static size(hash_table: never): number;
  // (i.e., function can't be called because the key type isn't string or number)

Example

See above. To validate, you could check that there are no GLib.HashTable parameters in the generated type definitions.

References

Additional Context

  • This affects other GJS types/classes
  • This is a regression from a previous version
  • This blocks other functionality

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions