Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why not directly compile rust code into a dll file #15

Open
sxhxliang opened this issue Apr 19, 2023 · 8 comments
Open

Why not directly compile rust code into a dll file #15

sxhxliang opened this issue Apr 19, 2023 · 8 comments

Comments

@sxhxliang
Copy link

          Ah yes, for now the configuration only supports x86-64. It shouldn't be too hard to add ARM64 support, PRs welcome.

I expect vcxproj and prebuild.ps1 to be modified in that case.

Originally posted by @saschanaz in #14 (comment)

@sxhxliang sxhxliang changed the title Ah yes, for now the configuration only supports x86-64. It shouldn't be too hard to add ARM64 support, PRs welcome. Why not directly compile rust code into a dll file Apr 19, 2023
@saschanaz
Copy link
Owner

Not sure what you want by that title. Even if there's a Rust dll file, that should still be loaded by the C++ part as it's not ported completely.

@sxhxliang
Copy link
Author

Not sure what you want by that title. Even if there's a Rust dll file, that should still be loaded by the C++ part as it's not ported completely.

The input method is essentially a dll file which exports four interfaces

EXPORTS
        DllGetClassObject               PRIVATE
        DllCanUnloadNow                 PRIVATE
        DllRegisterServer               PRIVATE
        DllUnregisterServer             PRIVATE

DllRegisterServer and DllUnregisterServer are registered (installation and uninstallation), that is, functions triggered when calling regsvr32.exe to register. for example regsvr32 cpp/x64/Debug/SampleIME.dll
I would like to explore the possibility of using rust to develop IME completely. In theory, rust can also export these four interfaces, and then use windows-rs to implement all of function in IME

@saschanaz
Copy link
Owner

I would like to explore the possibility of using rust to develop IME completely. In theory, rust can also export these four interfaces, and then use windows-rs to implement all of function in IME

Ah sure, it's the purpose of this repository. It's just not done yet.

@saschanaz
Copy link
Owner

saschanaz commented Apr 19, 2023

But I think that will be the last thing I'll do here, since for now the port is happening only in a way to call Rust things from C++ but not vise versa. Implementing the DLL interfaces right now will require calling C++ things from Rust which I'd rather not do. I'll only do it when I finish porting everything.

@sxhxliang
Copy link
Author

But I think that will be the last thing I'll do here, since for now the port is happening only in a way to call Rust things from C++ but not vise versa. Implementing the DLL interfaces right now will require calling C++ things from Rust which I'd rather not do. I'll only do it when I finish porting everything.

It is a good idea!
but I think we can refer to PIME and implement the core of SampleIME using rust.

Implement input methods easily for Windows via Text Services Framework:

LibIME contains a library which aims to be a simple wrapper for Windows Text Service Framework (TSF).
PIMETextService contains an backbone implementation of Windows text service for using libIME.
The python server part requires python 3.x and pywin32 package.

only migrate core Text Services Framework to rust first, input method engine can leverage existing open source projects, like RIME , librime-rs

@sxhxliang
Copy link
Author

This is a way to generate a similar DLL that can expose IME interface and make it available to windows.
https://stackoverflow.com/questions/75279682/implementing-a-windows-credential-provider

@saschanaz
Copy link
Owner

I see no value to generate DLL when the logic is still using C++.

I'm not deferring it just because I can't, as I already have done that in some other project. I just don't want to complicate things here as I described above.

BTW, the "core" logic is already ported, what's not ported is GUI part etc.

@sxhxliang
Copy link
Author

sxhxliang commented Apr 25, 2023

I see no value to generate DLL when the logic is still using C++.

I'm not deferring it just because I can't, as I already have done that in some other project. I just don't want to complicate things here as I described above.

BTW, the "core" logic is already ported, what's not ported is GUI part etc.

I found an IME GUI developed using rust
https://github.com/aiongg/khiin-rs/tree/master/windows/ime/src/ui

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants