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

Enum c support #72

Merged
merged 10 commits into from
May 12, 2021
Merged

Enum c support #72

merged 10 commits into from
May 12, 2021

Conversation

FelonEkonom
Copy link
Member

@FelonEkonom FelonEkonom commented Apr 14, 2021

Support for mapping C/C++ enums into Elixir atoms and vice versa

closes #61

@FelonEkonom FelonEkonom requested review from mickel8 and mat-hek April 14, 2021 14:38
@mickel8 mickel8 added the enhancement New feature or request label Apr 22, 2021
@@ -181,10 +181,14 @@ defmodule Unifex.Specs.DSL do

Elixir definition of %My.Struct{} should contain every field listed in specification and is not generated by Unifex
"""
defmacro type(struct) do
defmacro type({:"::", _, [_, {:%, _, _}]} = struct) do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update the doc, and also extend the example in the moduledoc so that it contained a struct and an enum

lib/unifex/code_generator/base_types/enum.ex Outdated Show resolved Hide resolved
lib/unifex/code_generator/base_types/enum.ex Outdated Show resolved Hide resolved
lib/unifex/code_generator/base_types/enum.ex Outdated Show resolved Hide resolved
test_projects/cnode/test/example_test.exs Outdated Show resolved Hide resolved
test_projects/nif/test/example_test.exs Outdated Show resolved Hide resolved
@FelonEkonom FelonEkonom requested review from mickel8 and mat-hek April 27, 2021 11:28
lib/unifex/specs_dsl.ex Outdated Show resolved Hide resolved
lib/unifex/code_generator/base_types/enum.ex Outdated Show resolved Hide resolved
#{if_condition} {
char* enum_as_string = "#{type}";
res = #{
BaseType.generate_arg_serialize(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's call the implementation directly here too

~g"""
char* enum_as_string = "#{type}";
#{
BaseType.generate_arg_serialize(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's call the implementation directly here too

@@ -0,0 +1,169 @@
defmodule Unifex.CodeGenerator.BaseTypes.Enum do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lot's of duplicated code in this module, let's reuse some parts

@FelonEkonom FelonEkonom requested review from mat-hek and mickel8 May 7, 2021 12:48
@FelonEkonom FelonEkonom requested a review from mickel8 May 11, 2021 14:51
@FelonEkonom FelonEkonom merged commit a67b379 into master May 12, 2021
@FelonEkonom FelonEkonom deleted the enum-C-support branch May 12, 2021 12:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support C enums
3 participants