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

support ffi_export on freestanding functions #2490

Closed
mversic opened this issue Jul 15, 2022 · 2 comments
Closed

support ffi_export on freestanding functions #2490

mversic opened this issue Jul 15, 2022 · 2 comments
Assignees
Labels
iroha2-dev The re-implementation of a BFT hyperledger in RUST

Comments

@mversic
Copy link
Contributor

mversic commented Jul 15, 2022

currently ffi_export supports only inherent impl blocks. Expanding the support to include freestanding functions should be very easy.

This function:

#[ffi_export]
fn some_fn(arg1: String, arg: &[u32]) {
    // ... do something ...
}

should produce, once macro is expanded, something like the following extern fn declaration:

extern fn __some_fn(arg1: <String as TryFromReprC>::Source, arg2: <&[u32] as TryFromReprC>::Source) {
    // ... generated code ...
}
@mversic mversic added the iroha2-dev The re-implementation of a BFT hyperledger in RUST label Jul 15, 2022
@ales-tsurko ales-tsurko self-assigned this Jul 25, 2022
@ales-tsurko
Copy link
Contributor

Should it support functions with return types either then ()? And if so, what kind of type should be returned? <T as TryFromReprC>::Source?

ales-tsurko added a commit to ales-tsurko/iroha that referenced this issue Jul 25, 2022
ales-tsurko added a commit to ales-tsurko/iroha that referenced this issue Jul 25, 2022
@mversic
Copy link
Contributor Author

mversic commented Jul 25, 2022

Should it support functions with return types either then ()? And if so, what kind of type should be returned? <T as TryFromReprC>::Source?

Yes, the type returned is <<T as IntoFfi>::Target as Output>::OutPtr. You can see this in the impl_visitor I believe

ales-tsurko added a commit to ales-tsurko/iroha that referenced this issue Jul 26, 2022
@mversic mversic added the Red label Jul 27, 2022
ales-tsurko added a commit to ales-tsurko/iroha that referenced this issue Jul 27, 2022
ales-tsurko added a commit to ales-tsurko/iroha that referenced this issue Jul 27, 2022
ales-tsurko added a commit to ales-tsurko/iroha that referenced this issue Jul 27, 2022
ales-tsurko added a commit to ales-tsurko/iroha that referenced this issue Jul 27, 2022
ales-tsurko added a commit to ales-tsurko/iroha that referenced this issue Jul 27, 2022
ales-tsurko added a commit to ales-tsurko/iroha that referenced this issue Jul 27, 2022
ales-tsurko added a commit to ales-tsurko/iroha that referenced this issue Jul 27, 2022
ales-tsurko added a commit to ales-tsurko/iroha that referenced this issue Jul 27, 2022
ales-tsurko added a commit to ales-tsurko/iroha that referenced this issue Jul 27, 2022
ales-tsurko added a commit to ales-tsurko/iroha that referenced this issue Jul 27, 2022
ales-tsurko added a commit to ales-tsurko/iroha that referenced this issue Jul 27, 2022
ales-tsurko added a commit to ales-tsurko/iroha that referenced this issue Jul 27, 2022
ales-tsurko added a commit to ales-tsurko/iroha that referenced this issue Jul 28, 2022
ales-tsurko added a commit to ales-tsurko/iroha that referenced this issue Jul 28, 2022
ales-tsurko added a commit to ales-tsurko/iroha that referenced this issue Jul 28, 2022
ales-tsurko added a commit to ales-tsurko/iroha that referenced this issue Jul 28, 2022
ales-tsurko added a commit to ales-tsurko/iroha that referenced this issue Jul 28, 2022
ales-tsurko added a commit to ales-tsurko/iroha that referenced this issue Jul 28, 2022
ales-tsurko added a commit to ales-tsurko/iroha that referenced this issue Jul 28, 2022
ales-tsurko added a commit to ales-tsurko/iroha that referenced this issue Jul 28, 2022
ales-tsurko added a commit that referenced this issue Jul 28, 2022
* [feature] #2490: Implement ffi_export attribute for freestanding functions

Signed-off-by: Ales Tsurko <[email protected]>

* [feature] #2490: Update gen_ffi_fn to handle free-standing functions

Signed-off-by: Ales Tsurko <[email protected]>

* [feature] #2490: Update tests

Signed-off-by: Ales Tsurko <[email protected]>
mversic pushed a commit to mversic/iroha that referenced this issue Sep 6, 2022
…ng functions (hyperledger-iroha#2538)

* [feature] hyperledger-iroha#2490: Implement ffi_export attribute for freestanding functions

Signed-off-by: Ales Tsurko <[email protected]>

* [feature] hyperledger-iroha#2490: Update gen_ffi_fn to handle free-standing functions

Signed-off-by: Ales Tsurko <[email protected]>

* [feature] hyperledger-iroha#2490: Update tests

Signed-off-by: Ales Tsurko <[email protected]>
mversic pushed a commit to mversic/iroha that referenced this issue Sep 6, 2022
…ng functions (hyperledger-iroha#2538)

* [feature] hyperledger-iroha#2490: Implement ffi_export attribute for freestanding functions

Signed-off-by: Ales Tsurko <[email protected]>

* [feature] hyperledger-iroha#2490: Update gen_ffi_fn to handle free-standing functions

Signed-off-by: Ales Tsurko <[email protected]>

* [feature] hyperledger-iroha#2490: Update tests

Signed-off-by: Ales Tsurko <[email protected]>
mversic pushed a commit to mversic/iroha that referenced this issue Sep 6, 2022
…ng functions (hyperledger-iroha#2538)

* [feature] hyperledger-iroha#2490: Implement ffi_export attribute for freestanding functions

Signed-off-by: Ales Tsurko <[email protected]>

* [feature] hyperledger-iroha#2490: Update gen_ffi_fn to handle free-standing functions

Signed-off-by: Ales Tsurko <[email protected]>

* [feature] hyperledger-iroha#2490: Update tests

Signed-off-by: Ales Tsurko <[email protected]>
mversic pushed a commit to mversic/iroha that referenced this issue Sep 7, 2022
…ng functions (hyperledger-iroha#2538)

* [feature] hyperledger-iroha#2490: Implement ffi_export attribute for freestanding functions

Signed-off-by: Ales Tsurko <[email protected]>

* [feature] hyperledger-iroha#2490: Update gen_ffi_fn to handle free-standing functions

Signed-off-by: Ales Tsurko <[email protected]>

* [feature] hyperledger-iroha#2490: Update tests

Signed-off-by: Ales Tsurko <[email protected]>
mversic pushed a commit to mversic/iroha that referenced this issue Sep 8, 2022
…ng functions (hyperledger-iroha#2538)

* [feature] hyperledger-iroha#2490: Implement ffi_export attribute for freestanding functions

Signed-off-by: Ales Tsurko <[email protected]>

* [feature] hyperledger-iroha#2490: Update gen_ffi_fn to handle free-standing functions

Signed-off-by: Ales Tsurko <[email protected]>

* [feature] hyperledger-iroha#2490: Update tests

Signed-off-by: Ales Tsurko <[email protected]>
mversic pushed a commit to mversic/iroha that referenced this issue Sep 9, 2022
…ng functions (hyperledger-iroha#2538)

* [feature] hyperledger-iroha#2490: Implement ffi_export attribute for freestanding functions

Signed-off-by: Ales Tsurko <[email protected]>

* [feature] hyperledger-iroha#2490: Update gen_ffi_fn to handle free-standing functions

Signed-off-by: Ales Tsurko <[email protected]>

* [feature] hyperledger-iroha#2490: Update tests

Signed-off-by: Ales Tsurko <[email protected]>
mversic pushed a commit to mversic/iroha that referenced this issue Sep 9, 2022
…ng functions (hyperledger-iroha#2538)

* [feature] hyperledger-iroha#2490: Implement ffi_export attribute for freestanding functions

Signed-off-by: Ales Tsurko <[email protected]>

* [feature] hyperledger-iroha#2490: Update gen_ffi_fn to handle free-standing functions

Signed-off-by: Ales Tsurko <[email protected]>

* [feature] hyperledger-iroha#2490: Update tests

Signed-off-by: Ales Tsurko <[email protected]>
mversic pushed a commit to mversic/iroha that referenced this issue Sep 9, 2022
…ng functions (hyperledger-iroha#2538)

* [feature] hyperledger-iroha#2490: Implement ffi_export attribute for freestanding functions

Signed-off-by: Ales Tsurko <[email protected]>

* [feature] hyperledger-iroha#2490: Update gen_ffi_fn to handle free-standing functions

Signed-off-by: Ales Tsurko <[email protected]>

* [feature] hyperledger-iroha#2490: Update tests

Signed-off-by: Ales Tsurko <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
iroha2-dev The re-implementation of a BFT hyperledger in RUST
Projects
None yet
Development

No branches or pull requests

2 participants