Generate fully qualified names for global c++ classes

Open
#1,181 0 comments 1 reaction 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
38/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
cpp
Domain
compilers

Research direction

Start by locating the hxcpp C++ code-generation entry point for global classes such as String, Array, and Dynamic, then reproduce the example inside a godot namespace. Verify which generated type references lack the global-scope prefix and compile the resulting code to confirm that fully qualified names avoid collisions with godot::String.

Written by the indexing model from the issue text.

Description

Summary:
For hxcpp classes not defined in namespace, e.g. ::String, ::Array and ::Dynamic, the compiler should always generate them with the :: prefix so they are fully qualified.

Rationale:
Working with godot lately and they have a C++ classgodot::String.
If we also declare a Haxe class like this:

package godot;

class Foo {
  public function print(str:String) {}
}

the generated c++ code will look somewhat like this:

namespace godot {
  class Foo {
    void print(str:String);
  }
}

and the c++ compiler would think that the function argument is a godot::String and causing c++ compilation errors.

Alternatively:
All these global hxcpp class should be moved to the hx namespace to be consistent with other classes.

Dominant language
C++
Stars
330
Forks
237
Avg merge
1d 3h
Merged PRs (30d)
20

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from HaxeFoundation/hxcpp

All issues in HaxeFoundation/hxcpp

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.