Skip to content

Export interface for external call#2131

Open
TaranDahl wants to merge 4 commits intoPhobos-developers:developfrom
TaranDahl:Interop
Open

Export interface for external call#2131
TaranDahl wants to merge 4 commits intoPhobos-developers:developfrom
TaranDahl:Interop

Conversation

@TaranDahl
Copy link
Copy Markdown
Contributor

@TaranDahl TaranDahl commented Mar 10, 2026

Interoperability

Phobos has opened the external interfaces of some key components. If you are also developing your own engine extension and wish to use Phobos at the same time, please check out Interop.

@TaranDahl TaranDahl requested a review from Copilot March 10, 2026 15:53
@TaranDahl TaranDahl added Interaction Something related to interaction with other extension, program etc. Needs testing ⚙️T3 labels Mar 10, 2026
@TaranDahl TaranDahl added the No Documentation Needed No documentation needed whatsoever label Mar 10, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a small C ABI “Interop” surface to Phobos so other engine extensions can call into selected Phobos systems at runtime (DLL exports), along with documentation/changelog entries announcing the feature.

Changes:

  • Introduces exported interop functions for TechnoExt::ConvertToType and AttachEffect attach/detach/transfer operations.
  • Wires the new interop sources into the MSBuild project.
  • Documents the new interoperability entry in README, Whats-New, and CREDITS.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/Interop/TechnoExt.h Declares exported ConvertToType_Phobos C ABI function.
src/Interop/TechnoExt.cpp Implements the exported type-conversion wrapper.
src/Interop/AttachEffect.h Declares exported C ABI functions for AttachEffect operations.
src/Interop/AttachEffect.cpp Implements exported wrappers for attaching/detaching/transferring effects.
docs/Whats-New.md Adds a changelog entry referencing the new interop feature.
README.md Adds an “Interoperability” section pointing to src/Interop.
Phobos.vcxproj Adds the new interop .cpp/.h files to the build.
CREDITS.md Adds credit entry for the interop export feature.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 10, 2026

Nightly build for this pull request:

This comment is automatic and is meant to allow guests to get latest nightly builds for this pull request without registering. It is updated on every successful build.

@Metadorius
Copy link
Copy Markdown
Member

I am not sure why all pointers are void*?

@ZivDero
Copy link
Copy Markdown
Contributor

ZivDero commented Mar 10, 2026

I am not sure why all pointers are void*?

My bet would be that to make it so that this does not depend on YRpp (in case someone is using their own implementation of YRpp, perhaps)

@TaranDahl
Copy link
Copy Markdown
Contributor Author

I am not sure why all pointers are void*?

Copilot said that if I use TechnoClass*, it will break the P/Invoke compatibility. When calling in C#, I can't directly use IntPtr. I have to do type mapping, otherwise the call will fail.

@Metadorius
Copy link
Copy Markdown
Member

Copilot said that if I use TechnoClass*, it will break the P/Invoke compatibility. When calling in C#, I can't directly use IntPtr. I have to do type mapping, otherwise the call will fail.

This sounds like AI hallucinations...

  1. You can have unsafe methods in which you can do whatever like pointers etc
  2. C# marshaller isn't as rigid as that usually

@TaranDahl
Copy link
Copy Markdown
Contributor Author

Copilot said that if I use TechnoClass*, it will break the P/Invoke compatibility. When calling in C#, I can't directly use IntPtr. I have to do type mapping, otherwise the call will fail.

This sounds like AI hallucinations...

  1. You can have unsafe methods in which you can do whatever like pointers etc
  2. C# marshaller isn't as rigid as that usually

Changed

@phoboscn-bot
Copy link
Copy Markdown

To Chinese users:
This pull request has been mentioned on Phobos CN. There might be relevant details there:

致中文用户:
此拉取请求已在 Phobos CN 上被提及。那里可能有相关详细信息:

https://www.phoboscn.top/t/topic/229/1

@secsome
Copy link
Copy Markdown
Member

secsome commented Mar 13, 2026

Macros like PHOBOS_EXPORT and PHOBOS_DECL can make the code cleaner and such macros are widely used in most projects.
Just an example:

#define PHOBOS_DECL __stdcall
#define PHOBOS_EXPORT extern "C" __declspec(dllexport) 

@DeathFishAtEase
Copy link
Copy Markdown
Collaborator

If you are also developing your own engine extension and wish to use Phobos at the same time

Would it be more appropriate to move the Changelog entry of this PR to the Fixes / interactions with other extensions section?

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

@DeathFishAtEase
Copy link
Copy Markdown
Collaborator

A question: how is the Tested status of this PR determined, as there seems to be no one using another engine extension to try out the content of this PR or other testing information.

@TaranDahl
Copy link
Copy Markdown
Contributor Author

A question: how is the Tested status of this PR determined, as there seems to be no one using another engine extension to try out the content of this PR or other testing information.

I tested the usability of the initial version myself using DP. However, the current version has not been tested yet.

@TaranDahl TaranDahl requested a review from secsome March 19, 2026 08:33
Copy link
Copy Markdown
Member

@secsome secsome left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Copy Markdown
Collaborator

@DeathFishAtEase DeathFishAtEase left a comment

Choose a reason for hiding this comment

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

Link redirection is correct.
You may consider filling in the Chinese translation before merging. I have created standard translation entries (don't worry about introducing errors; that will be handled subsequently by the Regular Revisions PR).

@Metadorius
Copy link
Copy Markdown
Member

I think one thing to consider would be the API versioning and backwards compatibility. Usually the APIs are somehow formatting. I am not saying this needs to be done regardless but we may need to employ sth like that.

Also, where docs?

@Metadorius Metadorius removed the No Documentation Needed No documentation needed whatsoever label Mar 28, 2026
core

core

Update AttachEffect.cpp

update

Update README.md

Update docs/Whats-New.md

update

Potential fix for pull request finding

Update Macro.h

Create .po entries

udpate

update

Update Phobos.vcxproj

Co-Authored-By: Noble Fish <89088785+DeathFishAtEase@users.noreply.github.com>
Co-Authored-By: Copilot <175728472+Copilot@users.noreply.github.com>
Co-Authored-By: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@TaranDahl
Copy link
Copy Markdown
Contributor Author

I think one thing to consider would be the API versioning and backwards compatibility. Usually the APIs are somehow formatting. I am not saying this needs to be done regardless but we may need to employ sth like that.

What exactly needs to be done?

Also, where docs?

I assume that engine developers are smart enough to read interface declarations 🤔

@Metadorius
Copy link
Copy Markdown
Member

What exactly needs to be done?

I mean, you tell me :P

I said this as an open question, something to think about.

I assume that engine developers are smart enough to read interface declarations 🤔

don't be one of the "just read the code" people :P

also interface declaration doesn't say anything about how to set up your project to be able to call Phobos, and we should provide that info

@Metadorius
Copy link
Copy Markdown
Member

One thing to note: you can write documentation as docstrings, and have Sphinx (doxygen?) generate the corresponding pages. I think there was such an ability. Would be cool to look into that.

@Metadorius
Copy link
Copy Markdown
Member

https://www.sphinx-doc.org/en/master/usage/extensions/autodoc.html

@DeathFishAtEase
Copy link
Copy Markdown
Collaborator

If using Sphinx to generate documentation is not convenient, you can first try using forum posts and comments as carriers on the Phobos CN forum and GitHub PR page.

@TaranDahl
Copy link
Copy Markdown
Contributor Author

@Metadorius I asked AI to write one. Take a look at it.

Copy link
Copy Markdown
Collaborator

@DeathFishAtEase DeathFishAtEase left a comment

Choose a reason for hiding this comment

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

The current path is incorrect.

Co-authored-by: Noble Fish <89088785+DeathFishAtEase@users.noreply.github.com>

DEFINE_EXPORT(unsigned int, GetInteropBuildNumber)
{
return BUILD_NUMBER;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Seems too imprecise (given that it's just 48 right now). Should be a number that increments, yes, but more detailed.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I also dislike latching on to build numbers which will go away when/if we switch to the proposed versioning

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

but more detailed

Is it really necessary to be specific to nightly?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I also dislike latching on to build numbers which will go away when/if we switch to the proposed versioning

Then what number should be used?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

usually APIs are versioned separately. like v1, v2, v3...

btw, deprecated means "it still works, but a newer method exists which is recommended", not "not working"

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

Labels

Interaction Something related to interaction with other extension, program etc. Needs testing ⚙️T3

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants