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

C addons #1

Open
libkakashi opened this issue Aug 29, 2020 · 1 comment
Open

C addons #1

libkakashi opened this issue Aug 29, 2020 · 1 comment

Comments

@libkakashi
Copy link
Member

The current way of interacting with c APIs is to prefix an identifier with the dollar sign ($). For example,

import "header.h";

func main() i32 {
    $a_function_defined_in_header(...args);
    return 0;
}

The identifiers starting with a dollar sign are not type-checked for obvious reasons. This approach is very simple and straight forward but it is very unsafe and can cause serious issues in large applications.
Volant needs a more safe and robust way of managing c addons. The specific details of how that system will work are not yet fully decided but here's a rough idea for how the addons will work,

import "header.h";

// defining a foreign type
typedef foreign a_type_defined_header;

// defining a foreign function
func foreign a_function_defined_in_header(arg1: type1, ...) returnType;

// defining a foreign variable
a_variable_defined_in_header: foreign type;

This way, type-checking can be implemented for c-addons making them safe to use.

But there are a couple of things that make it hard for us to implement this,

  • Volant functions are blocks, and there is so standard way to work with c functions in Volant.
  • In Volant, enums, structs, and unions are typedef-ed internally, and Volant isn't compatible with types that aren't typedef-ed.

If you have any good ideas about how we can solve these problems, we would love to hear them.

@libkakashi libkakashi added enhancement New feature or request help wanted Extra attention is needed labels Aug 29, 2020
@libkakashi libkakashi removed help wanted Extra attention is needed enhancement New feature or request labels Sep 28, 2020
@libkakashi
Copy link
Member Author

git is weird :thonk:

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

No branches or pull requests

1 participant