Ark icon indicating copy to clipboard operation
Ark copied to clipboard

Enhance module interface

Open SuperFola opened this issue 3 years ago • 0 comments

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

SuperFola avatar Jun 10 '21 11:06 SuperFola