Rantanen / intercom

Object based cross-language FFI for Rust
MIT License
63 stars 7 forks source link

Compiler Error: Found Removed 'do catch' Syntax #115

Closed Neightro closed 4 years ago

Neightro commented 4 years ago

I received this error from Cargo when attempting to compile intercom-attributes 0.2.0. I have configured the build to use the nightly toolchain by placing a file called rust-toolchain in the root of the project.

According to the error, the instance of the syntax can be found at src/lib.rs:177:9 of intercom-attributes. Is the version of the crate published on crates.io out of date? I checked the current version of the file on the Master branch, and there isn't a line 177, let alone 'do catch' syntax.

Rantanen commented 4 years ago

Yeah, sorry. The crates.io version was badly outdated.

I've now pushed the current master branch there. While there is still a pile of functionality missing and we've discussed a somewhat large refactoring to the way types and their conversions are described, the current master should work for the basic use cases - we are already internally using certain COM APIs in Windows and the tests do cover many other use cases.

Neightro commented 4 years ago

Thanks for the quick response!

Are you saying there is functionality missing from the current master of intercom-attributes? What are the current use cases that aren't covered?

By the way, the #[com_interface] in the example is panicking on me with a syntax error. Is there something I need to do to use the example properly?

Rantanen commented 4 years ago

Oh, the README.md hasn't been updated either it seems! Oops. :)

You can use the tests\testlib as an example for now.

https://github.com/Rantanen/intercom/blob/master/test/testlib/src/lib.rs https://github.com/Rantanen/intercom/blob/master/test/testlib/src/stateful.rs

Are you saying there is functionality missing from the current master of intercom-attributes? What are the current use cases that aren't covered?

Defining your own types with custom marshalling, using structs, implementing ITypeInfo and IDispatch and supporting COM registration are the current big ones. There could very well be a pile that haven't even been considered though.

Neightro commented 4 years ago

Thanks for the links; I tried the stateful example and it seems to have compiled properly! I'll have to test opening it.

When you say structs aren't supported right now, what do you mean? Do you mean using Rust types as arguments for methods?

Rantanen commented 4 years ago

Technically any repr_c-compatible type should be compatible as arguments, however the included IDL generation (as part of intercom-cli/intercom-build crates) does not have support for resolving such types - I guess we'd need #[com_struct] attribute to mark these for IDL-export.

As a result, using custom Rust-types (#[repr_c] structs for example) will result in IDL files that won't compile. I'd imagine manually writing the IDL files should still be possible.

If you are just implementing existing IDL files in Rust, this might not be a problem at all.

In any case this is very untested area. I can't come up with reasons this shouldn't work, but I don't think there is a single test that ensures this works currently.

Rantanen commented 4 years ago

And just to clarify, using Rust types behind COM interfaces should work just fine (https://github.com/Rantanen/intercom/blob/master/test/testlib/src/interface_params.rs, https://github.com/Rantanen/intercom/blob/master/test/testlib/src/return_interfaces.rs).