Skip to content

Enhance module interface #275

Closed
Closed
@SuperFola

Description

@SuperFola

What I'm talking about is this:

https://github.com/ArkScript-lang/modules/blob/master/console/src/main.cpp#L94-L101

We need a C API so that won't change, but having to know how many fields we need to allocate, and keep track of the position of each field/value (through map[index]) is very bad.

I think it's possible to do a

mapping_t* get() {
  mapping_t data[] = {
    {"name", function},
    // ...
    NULL  // sentinel
  };
  return data;
}

but it needs tests and modifications to the VM (to avoid putting a delete), or maybe even enhance module API to add a delete_mapping(mapping_t*) so that any module developper can choose how to deallocate memory

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    v4.0.0

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions