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 items not expanded when being used as arguments to constructor in default argument #1822

Open
trungnt2910 opened this issue Jan 29, 2024 · 0 comments

Comments

@trungnt2910
Copy link
Contributor

Brief Description

OS: Windows / OS X / Linux (Ubuntu 23.04)

Used headers

SeparatorView.h from Haiku: https://github.com/haiku/haiku/blob/master/headers/os/interface/SeparatorView.h

with this declaration:

	BSeparatorView(BView* labelView,
		orientation orientation = B_HORIZONTAL,
		border_style border = B_FANCY_BORDER,
		const BAlignment& alignment
			= BAlignment(B_ALIGN_HORIZONTAL_CENTER,
				B_ALIGN_VERTICAL_CENTER));
Used settings

Target: MSVC/GCC/Clang

Other settings

Stack trace or incompilable generated code

Generated code:

        public BSeparatorView(string name, string label, global::Haiku.Interface.Orientation orientation = global::Haiku.Interface.Orientation.Horizontal, global::Haiku.Interface.BorderStyle border = global::Haiku.Interface.BorderStyle.FancyBorder) : this(name, label, orientation, border, new global::Haiku.Interface.BAlignment(B_ALIGN_HORIZONTAL_CENTER, B_ALIGN_VERTICAL_CENTER))
        {
        }

Interesting part:

new global::Haiku.Interface.BAlignment(B_ALIGN_HORIZONTAL_CENTER, B_ALIGN_VERTICAL_CENTER)

Compile error:

/home/trung/cppsharp/generated/Interface.cs(80086,330): error CS0103: The name 'B_ALIGN_HORIZONTAL_CENTER' does not exist in the current context [/home/trung/cppsharp/HaikuApiGenerator.csproj]

Probable cause:

if (constructorExpr.Arguments.Count == 1 &&
constructorExpr.Arguments[0].Class != StatementClass.Any)
return VisitExpression(constructorExpr.Arguments[0]);

The C# generator only expands into constructors and resolve enums when the constructor contains only one argument.

trungnt2910 added a commit to trungnt2910/dotnet-haiku that referenced this issue Jan 29, 2024
- Only put top-level enums into the `Symbols` class. Otherwise, name
clashes may occur. Furthermore, it does not make sense to allow direct
access to nested enums in C# code, as they require entering the class
scope in the original C++ code.
- Add some regex hacks for mono/CppSharp#1822.

Everything should build again after
https://review.haiku-os.org/c/haiku/+/7377 gets merged into Haiku.
trungnt2910 added a commit to trungnt2910/dotnet-haiku that referenced this issue Jan 29, 2024
- Only put top-level enums into the `Symbols` class. Otherwise, name
clashes may occur. Furthermore, it does not make sense to allow direct
access to nested enums in C# code, as they require entering the class
scope in the original C++ code.
- Add some regex hacks for mono/CppSharp#1822.

Everything should build again after
https://review.haiku-os.org/c/haiku/+/7377 gets merged into Haiku.
trungnt2910 added a commit to trungnt2910/dotnet-haiku that referenced this issue Jan 29, 2024
- Only put top-level enums into the `Symbols` class. Otherwise, name
clashes may occur. Furthermore, it does not make sense to allow direct
access to nested enums in C# code, as they require entering the class
scope in the original C++ code.
- Add some regex hacks for mono/CppSharp#1822.

Everything should build again after
https://review.haiku-os.org/c/haiku/+/7377 gets merged into Haiku.
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