| // Part of the Crubit project, under the Apache License v2.0 with LLVM |
| // Exceptions. See /LICENSE for license information. |
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| #include "rs_bindings_from_cc/src_code_gen.h" |
| #include "rs_bindings_from_cc/ir.h" |
| #include "testing/base/public/gmock.h" |
| #include "testing/base/public/gunit.h" |
| #include "third_party/absl/strings/cord.h" |
| namespace rs_bindings_from_cc { |
| TEST(SrcGenTest, FFIIntegration) { |
| Identifier(absl::Cord("hello_world")), absl::Cord("$$mangled_name$$"), |
| {FuncParam(Type(absl::Cord("i32")), Identifier(absl::Cord("arg")))})}); |
| std::string rs_api = GenerateRustApi(ir); |
| // TODO(hlopko): Run generated sources through rustfmt. |
| "pub fn hello_world (arg : i32) -> i32 { " |
| "unsafe { crate :: detail :: __rust_thunk__hello_world (arg) } " |
| "# [link_name = \"$$mangled_name$$\"] " |
| "pub (crate) fn __rust_thunk__hello_world (arg : i32) -> i32 ; " |
| } // namespace rs_bindings_from_cc |