Skip to content

Conversation

@dsnopek
Copy link
Contributor

@dsnopek dsnopek commented Nov 7, 2024

Possibly fixes godotengine/godot-cpp#1636

I don't personally know this API, so I don't know if this is the right fix, but throwing this up here either as the fix (if the folks who know this API think this is the right way to do it), or as an example for someone else to take over.

@MXKhronos
Copy link

Would like to see this added soon.

@dsnopek
Copy link
Contributor Author

dsnopek commented Apr 28, 2025

@MXKhronos Do you have a project to test this with? I don't really know these APIs nor have anything setup to test it, which is why this is still marked as a draft

@MXKhronos
Copy link

MXKhronos commented Apr 28, 2025

@MXKhronos Do you have a project to test this with? I don't really know these APIs nor have anything setup to test it, which is why this is still marked as a draft

Yeah, I'm working & learning to add Luau to Godot via a gdextension mimicking the godot/modules/gdscript approach but I have not yet figured out how to get godot-cpp bindings from my custom godot build with this pull's commits.

https://github.com/MXKhronos/LuauGDExtension

It's in src/luauscript/luauscript_syntax_highlighter.h but it's not an override at the moment.

My build gets the same issue as the issue in the post.

@dsnopek
Copy link
Contributor Author

dsnopek commented Jun 7, 2025

My build gets the same issue as the issue in the post.

@MXKhronos Have you tested if this PR helps to fix the issue for you?

@MXKhronos
Copy link

@MXKhronos Have you tested if this PR helps to fix the issue for you?

Sorry, I'm new to this. How do I generate cpp bindings from my custom godot build to test it? I've tried adding generate_bindings=yes to the scons args and it didn't seem to generate anything new when I compile.

I ran scons target=editor generate_bindings=yes

@dsnopek
Copy link
Contributor Author

dsnopek commented Jun 8, 2025

You need to first build Godot with this PR, and then you can run godot --dump-extension-api which will make a new extension_api.json. Then when building your GDExtension, you can either replace the existing extension_api.json, or just point to it (with godot-cpp and scons, that's scons custom_api_file=path/to/extension_api.json). That should make the new EditorSyntaxHighlighter::_create() virtual method available to your extension

@MXKhronos
Copy link

Thanks!

It compile, runs and seems fix, that's all my extension does atm.

Ref<EditorSyntaxHighlighter> EditorSyntaxHighlighter::_create() const {
	Ref<EditorSyntaxHighlighter> syntax_highlighter;
	if (GDVIRTUAL_IS_OVERRIDDEN(_create)) {
		print_verbose("Using overridden syntax highlighter");
		GDVIRTUAL_CALL(_create, syntax_highlighter);
	} else {
		print_verbose("Using default syntax highlighter");
		syntax_highlighter.instantiate();
		if (get_script_instance()) {
			syntax_highlighter->set_script(get_script_instance()->get_script());
		}
	}
	return syntax_highlighter;
}

image

@dsnopek
Copy link
Contributor Author

dsnopek commented Jun 9, 2025

Thanks for testing! I'll take this out of DRAFT then :-)

@dsnopek dsnopek changed the title [DRAFT] Expose the EditorScriptHighlighter::_create() method to GDExtension Expose the EditorScriptHighlighter::_create() method to GDExtension Jun 9, 2025
@dsnopek dsnopek marked this pull request as ready for review June 9, 2025 12:15
@akien-mga akien-mga modified the milestones: 4.x, 4.5 Jun 10, 2025
@akien-mga akien-mga merged commit 7b9e7b9 into godotengine:master Jun 10, 2025
@akien-mga
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

EditorSyntaxHighlighter is missing _create()

3 participants