Skip to content

feat: support direct Swift class instantiation with typed reflection and ptrcall - #15

Open
gumaciel wants to merge 1 commit into
masterfrom
feat/14-direct-class-instantiation
Open

gumaciel wants to merge 1 commit into
masterfrom
feat/14-direct-class-instantiation

Conversation

@gumaciel

Copy link
Copy Markdown
Contributor

Resolves #14

Summary

• Direct Swift Class Instantiation: Allows developers to instantiate registered Swift classes directly via GDScript .new() (e.g. var plugin := GodotExamplePlugin.new()), completely eliminating the need for GDScript wrapper files and Engine.has_singleton().
• ClassDB Parameter & Return Type Introspection: Extracts concrete argument counts, parameter names, and return types from Objective-C selectors in GodotRuntimeDispatcher and populates GodotClassDB method definitions so GDScript's compile-time signature checks pass without error.
• High-Performance ptrcall Dispatch: Implements direct GDExtension ptrcall dispatch for typed class invocations, bypassing intermediate Variant conversions.
• Clean Parameter Names & Duplicate Suppression: Parses selector component labels to produce idiomatic GDScript argument names (e.g. add_numbers(a, b) instead of arg0, arg1), and suppresses duplicate selector aliases that clash in ClassDB.
• Interactive Direct Sample Scene: Added sample/direct_sample.tscn and sample/direct_sample.gd to demonstrate direct instance usage and dynamic runtime switching in the example project.

Verification

  • swift test (All 9 unit tests passing)
  • swift test --package-path example/apple (All 3 example tests passing)
  • gdlint example/godot_editor/ (0 lint warnings/errors)

…rcall

- Add direct Swift class instantiation support via GDScript .new()
- Reflect concrete method argument and return types into Godot ClassDB
- Extract clean parameter names and suppress duplicate selector aliases
- Implement high-performance GDExtension ptrcall dispatch for typed calls
- Add direct class sample scene and interactive toggle in example project
@poing-ai poing-ai Bot added enhancement New feature or request medium priority Medium priority issue labels Sep 20, 2026

@poing-ai poing-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Poing AI

Commit: ca27f716ae · Model: gemini-3.5-flash-lite

✅ Approved

Adds direct Swift class instantiation support with typed reflection and ptrcall capabilities for Godot GDExtension integration, along with accompanying sample scenes.


ℹ️ About Poing AI

Poing AI is an enterprise-grade AI code reviewer and guidelines verifier for Godot, Unity, Unreal, and multi-platform repositories.

Commands:

  • Comment /review or @poing-ai review on this PR to run a fresh review.
  • Comment /fix or @poing-ai fix on this PR to trigger autonomous code repair.

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

Labels

enhancement New feature or request medium priority Medium priority issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support direct Swift class instantiation (no GDScript wrapper, no Engine.has_singleton)

1 participant