Skip to content

[feat]: Implement generic C++ vector interop for C# scripting system #374

Description

@coderabbitai

Objective

Implement a generic solution for handling C++ std::vector containers in the C# scripting system, starting with the missing children field in the Transform component.

Acceptance Criteria

  • Design and implement a generic interop layer for C++ std::vector to C# collections
  • Add the missing children field to the Transform C# struct
  • Ensure memory safety and proper lifetime management for vector data
  • Implement efficient marshaling without unnecessary copies
  • Provide a consistent API pattern for future C++ container interop
  • Add unit tests for the interop functionality
  • Update documentation with usage examples

Dependencies

  • Current C++/C# interop infrastructure
  • Transform component implementation in both C++ and C#
  • Existing scripting system architecture

Technical Details

Environment: Windows/Linux cross-platform
Components: Scripting system, Transform component, C++/C# interop layer
Resources:

  • Current Transform.cs struct lacks children field due to C++ vector interop limitations
  • Need to handle std::vector generically for multiple component types
  • Consider performance implications of marshaling collections

Suggested Technical Solutions:

  1. Wrapper Approach: Create C++ wrapper functions that expose vector operations through C-style interfaces
  2. Marshaling Helper: Implement generic marshaling utilities that convert std::vector to C# arrays/lists
  3. Interface Abstraction: Design C# interfaces that abstract away the underlying C++ container implementation
  4. Callback Pattern: Use function pointers/delegates to iterate over C++ vectors from C# side

Implementation Considerations:

  • Memory ownership and lifecycle management
  • Performance optimization for frequent access patterns
  • Type safety across language boundaries
  • Integration with existing component system

Context:

  • Related to PR feat: add scripting with .NET Core hosting #281 comment thread about Transform component updates
  • Current Transform.cs has a TODO comment for missing children field
  • NativeInterop.cs shows existing pattern for accessing Transform from C#

Activity

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions