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

Export C functions for other languages #336

Merged
merged 1 commit into from
May 20, 2023

Conversation

kabili207
Copy link
Contributor

Description:

This change exports the necessary decoder functions in C-style so they can be called by other languages. It's heavily based on the Python version already included.

Tested successfully with C# and Go

Checklist:

  • The pull request is done against the latest development branch
  • Only one feature/fix was added per PR and the code change compiles without warnings
  • I accept the DCO.

@koenvervloesem
Copy link
Member

This is interesting. Is it also possible to include sample code for C# and/or Go, like the Python example in the examples directory?

@kabili207
Copy link
Contributor Author

I've added an example for Go, as well as squashed and rebased my commits.

I won't have access to the windows machine for a few days, so a proper C# example will have to wait, but the function declarations below should be the bare minimum to work with the library. A proper C# example would wrap these inside a class but, as I said, no access to windows at the moment.

[DllImport("decoder.dll")]
public static extern IntPtr Theengs_NewDecoder();

[DllImport("decoder.dll")]
public static extern void Theengs_DestroyDecoder(IntPtr pointer);

[DllImport("decoder.dll")]
public static extern string Theengs_DecodeBLE(IntPtr pointer, string json_data);

[DllImport("decoder.dll")]
public static extern string Theengs_GetProperties(IntPtr pointer, string model_id);

[DllImport("decoder.dll")]
public static extern string Theengs_GetAttribute(IntPtr pointer, string model_id, string attribute);

@1technophile
Copy link
Member

That's great thanks!

@DigiH
Copy link
Contributor

DigiH commented May 19, 2023

Thanks @kabili207 !

Do you want to wait for being back on your Windows machine to add a C# example example to this PR, or do you want to do this later with a separate PR?

@kabili207
Copy link
Contributor Author

I can make a separate pull request for the C# example

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

Successfully merging this pull request may close these issues.

4 participants