├── .gitmodules
├── native_api_1c_macro
├── .gitignore
├── src
│ ├── derive_addin
│ │ ├── props
│ │ │ ├── generate.rs
│ │ │ ├── mod.rs
│ │ │ ├── collectors
│ │ │ │ ├── mod.rs
│ │ │ │ ├── get_n_props.rs
│ │ │ │ ├── is_prop_writable.rs
│ │ │ │ ├── is_prop_readable.rs
│ │ │ │ ├── get_prop_name.rs
│ │ │ │ ├── find_prop.rs
│ │ │ │ ├── get_prop_val.rs
│ │ │ │ └── set_prop_val.rs
│ │ │ └── parse.rs
│ │ ├── constants.rs
│ │ ├── functions
│ │ │ ├── collectors
│ │ │ │ ├── mod.rs
│ │ │ │ ├── get_n_methods.rs
│ │ │ │ ├── get_n_params.rs
│ │ │ │ ├── has_ret_val.rs
│ │ │ │ ├── call_as_proc.rs
│ │ │ │ ├── find_method.rs
│ │ │ │ ├── get_method_name.rs
│ │ │ │ ├── call_as_func.rs
│ │ │ │ └── get_param_def_value.rs
│ │ │ ├── generate.rs
│ │ │ ├── mod.rs
│ │ │ └── parse.rs
│ │ ├── utils.rs
│ │ ├── mod.rs
│ │ └── parsers.rs
│ ├── lib.rs
│ └── extern_functions
│ │ ├── parse.rs
│ │ └── mod.rs
├── tests
│ ├── trybuild
│ │ ├── to_build
│ │ │ ├── functions
│ │ │ │ ├── defaults
│ │ │ │ │ ├── date_type.stderr
│ │ │ │ │ ├── blob_type.stderr
│ │ │ │ │ ├── int_type.rs
│ │ │ │ │ ├── bool_type.rs
│ │ │ │ │ ├── float_type.rs
│ │ │ │ │ ├── str_type.rs
│ │ │ │ │ ├── blob_type.rs
│ │ │ │ │ └── date_type.rs
│ │ │ │ ├── int_type.rs
│ │ │ │ ├── bool_type.rs
│ │ │ │ ├── float_type.rs
│ │ │ │ ├── str_type.rs
│ │ │ │ ├── blob_type.rs
│ │ │ │ ├── result
│ │ │ │ │ ├── int_type.rs
│ │ │ │ │ ├── bool_type.rs
│ │ │ │ │ ├── float_type.rs
│ │ │ │ │ ├── str_type.rs
│ │ │ │ │ ├── blob_type.rs
│ │ │ │ │ └── date_type.rs
│ │ │ │ ├── date_type.rs
│ │ │ │ └── out_params
│ │ │ │ │ ├── int_type.rs
│ │ │ │ │ ├── bool_type.rs
│ │ │ │ │ ├── float_type.rs
│ │ │ │ │ ├── blob_type.rs
│ │ │ │ │ └── str_type.rs
│ │ │ └── props.rs
│ │ └── tests.rs
│ └── interface
│ │ ├── props.rs
│ │ └── functions.rs
├── .github
│ └── workflows
│ │ └── rust.yml
├── Cargo.toml
├── LICENSE
└── README.md
├── native_api_1c_core
├── rustfmt.toml
├── .gitignore
├── Cargo.toml
├── src
│ ├── lib.rs
│ ├── ffi
│ │ ├── locale_base.rs
│ │ ├── user_lang_base.rs
│ │ ├── init_base.rs
│ │ ├── init_done.rs
│ │ ├── string_utils.rs
│ │ ├── memory_manager.rs
│ │ ├── mod.rs
│ │ ├── connection.rs
│ │ ├── lang_extender.rs
│ │ └── provided_types.rs
│ └── interface.rs
├── README.md
└── LICENSE
├── .gitignore
├── native_api_1c
├── src
│ └── lib.rs
├── Cargo.toml
└── LICENSE
├── sample_addin_rs
├── Cargo.toml
└── src
│ └── lib.rs
├── Cargo.toml
├── .github
└── workflows
│ └── test.yml
└── README.md
/.gitmodules:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/native_api_1c_macro/.gitignore:
--------------------------------------------------------------------------------
1 | /target
2 |
--------------------------------------------------------------------------------
/native_api_1c_core/rustfmt.toml:
--------------------------------------------------------------------------------
1 | max_width = 80
2 |
--------------------------------------------------------------------------------
/native_api_1c_macro/src/derive_addin/props/generate.rs:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/native_api_1c_core/.gitignore:
--------------------------------------------------------------------------------
1 | target
2 | Cargo.lock
3 | .vscode
4 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ./sample_addin_rs
2 | target/
3 | Cargo.lock
4 | expand.rs
5 | lcov.info
--------------------------------------------------------------------------------
/native_api_1c/src/lib.rs:
--------------------------------------------------------------------------------
1 | pub extern crate native_api_1c_core;
2 | #[cfg(feature = "macro")]
3 | pub extern crate native_api_1c_macro;
4 |
--------------------------------------------------------------------------------
/sample_addin_rs/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "sample_addin_rs"
3 | version = "0.1.0"
4 | edition = "2021"
5 |
6 | [lib]
7 | crate-type = ["cdylib"]
8 |
9 | [dependencies]
10 | utf16_lit = "2.0"
11 | native_api_1c = { path = "../native_api_1c" }
12 | chrono = "0.4.26"
13 |
--------------------------------------------------------------------------------
/native_api_1c_macro/tests/trybuild/to_build/functions/defaults/date_type.stderr:
--------------------------------------------------------------------------------
1 | error: Type `Date` cannot have default value
2 | --> tests/trybuild/to_build/functions/defaults/date_type.rs:12:22
3 | |
4 | 12 | #[arg(ty = Date, default = "2021-01-01T00:00:00+00:00")]
5 | | ^^^^^^^
6 |
--------------------------------------------------------------------------------
/native_api_1c_macro/tests/trybuild/to_build/functions/defaults/blob_type.stderr:
--------------------------------------------------------------------------------
1 | error: Type `Blob` cannot have default value
2 | --> tests/trybuild/to_build/functions/defaults/blob_type.rs:12:22
3 | |
4 | 12 | #[arg(ty = Blob, default = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])]
5 | | ^^^^^^^
6 |
--------------------------------------------------------------------------------
/Cargo.toml:
--------------------------------------------------------------------------------
1 | [workspace]
2 | members = [
3 | "native_api_1c",
4 | "native_api_1c_core",
5 | "native_api_1c_macro",
6 | "sample_addin_rs",
7 | ]
8 |
9 | [patch.crates-io]
10 | native_api_1c = { path = "native_api_1c" }
11 | native_api_1c_core = { path = "native_api_1c_core" }
12 | native_api_1c_macro = { path = "native_api_1c_macro" }
13 |
--------------------------------------------------------------------------------
/native_api_1c_core/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "native_api_1c_core"
3 | version = "0.9.4"
4 | edition = "2021"
5 | repository = "https://github.com/Sebekerga/native_api_1c"
6 | license = "MIT"
7 | description = "Core library for Native API 1C"
8 |
9 | [dependencies]
10 | utf16_lit = "2.0"
11 | syn = { version = "2.0.28", features = ["full"] }
12 | quote = "1.0.32"
13 | chrono = "0.4.26"
14 |
--------------------------------------------------------------------------------
/native_api_1c_macro/src/derive_addin/props/mod.rs:
--------------------------------------------------------------------------------
1 | use proc_macro2::{Ident, TokenStream};
2 |
3 | use super::parsers::ParamType;
4 |
5 | pub mod collectors;
6 | pub mod generate;
7 | pub mod parse;
8 |
9 | #[derive(Debug)]
10 | pub struct PropDesc {
11 | pub ident: Ident,
12 |
13 | pub name_literal: TokenStream,
14 | pub name_ru_literal: TokenStream,
15 |
16 | pub readable: bool,
17 | pub writable: bool,
18 | pub ty: ParamType,
19 | }
20 |
--------------------------------------------------------------------------------
/native_api_1c_macro/src/lib.rs:
--------------------------------------------------------------------------------
1 | mod derive_addin;
2 | mod extern_functions;
3 |
4 | #[proc_macro_derive(AddIn, attributes(add_in_prop, add_in_func, add_in_con, arg, returns))]
5 | pub fn derive(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
6 | derive_addin::derive(input)
7 | }
8 |
9 | #[proc_macro]
10 | pub fn extern_functions(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
11 | extern_functions::extern_functions(input)
12 | }
13 |
--------------------------------------------------------------------------------
/native_api_1c/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "native_api_1c"
3 | version = "0.10.7"
4 | edition = "2021"
5 | repository = "https://github.com/Sebekerga/native_api_1c"
6 | license = "MIT"
7 | description = "Main library for Native API 1C"
8 | readme = "../README.md"
9 |
10 | [dependencies]
11 | native_api_1c_core = { path = "../native_api_1c_core" }
12 | native_api_1c_macro = { path = "../native_api_1c_macro" }
13 |
14 | [features]
15 | default = ["macro"]
16 | macro = []
17 |
--------------------------------------------------------------------------------
/native_api_1c_macro/.github/workflows/rust.yml:
--------------------------------------------------------------------------------
1 | name: Rust
2 |
3 | on:
4 | push:
5 | branches: [ "main" ]
6 | pull_request:
7 | branches: [ "main" ]
8 |
9 | env:
10 | CARGO_TERM_COLOR: always
11 |
12 | jobs:
13 | build:
14 |
15 | runs-on: ubuntu-latest
16 |
17 | steps:
18 | - uses: actions/checkout@v3
19 | - name: Install mingw-w64
20 | run: sudo apt-get -y install mingw-w64
21 | - name: Install target
22 | run: rustup target add x86_64-pc-windows-gnu
23 | - name: Build
24 | run: cargo build --target=x86_64-pc-windows-gnu --verbose
25 | - name: Run tests
26 | run: cargo test --verbose
27 |
--------------------------------------------------------------------------------
/native_api_1c_core/src/lib.rs:
--------------------------------------------------------------------------------
1 | //! Crate for working with 1C:Enterprise Native API. It contains
2 | //! low level FFI, moved from original C++ implementation, and high level
3 | //! interface for working with Native API from RUST. It attempts to be as
4 | //! close to original C++ implementation as possible, but some changes are
5 | //! made to make it more idiomatic in RUST.
6 | //!
7 | //! While it is possible to use this crate to implement your Native API
8 | //! Component, it is intended to be used with native_api_1c crate.
9 |
10 | /// Module for implementations of Native API FFI
11 | pub mod ffi;
12 | /// Module for high level interface of Native API
13 | pub mod interface;
14 |
--------------------------------------------------------------------------------
/native_api_1c_macro/src/derive_addin/constants.rs:
--------------------------------------------------------------------------------
1 | pub const BOOL_TYPE: &str = "Bool";
2 | pub const I32_TYPE: &str = "Int";
3 | pub const F64_TYPE: &str = "Float";
4 | pub const STRING_TYPE: &str = "Str";
5 | pub const DATE_TYPE: &str = "Date";
6 | pub const BLOB_TYPE: &str = "Blob";
7 | pub const UNTYPED_TYPE: &str = "None";
8 |
9 | pub const ALL_RETURN_TYPES: &[&str] = &[
10 | BOOL_TYPE,
11 | I32_TYPE,
12 | F64_TYPE,
13 | STRING_TYPE,
14 | DATE_TYPE,
15 | BLOB_TYPE,
16 | UNTYPED_TYPE,
17 | ];
18 | pub const ALL_ARG_TYPES: &[&str] = &[
19 | BOOL_TYPE,
20 | I32_TYPE,
21 | F64_TYPE,
22 | STRING_TYPE,
23 | DATE_TYPE,
24 | BLOB_TYPE,
25 | ];
26 |
--------------------------------------------------------------------------------
/.github/workflows/test.yml:
--------------------------------------------------------------------------------
1 | name: Rust
2 |
3 | on:
4 | push:
5 | pull_request:
6 |
7 | env:
8 | CARGO_TERM_COLOR: always
9 |
10 | jobs:
11 | build-sample-addin:
12 |
13 | runs-on: ubuntu-latest
14 |
15 | steps:
16 | - uses: actions/checkout@v3
17 | - name: Install mingw-w64
18 | run: sudo apt-get -y install mingw-w64
19 | - name: Build sample AddIn
20 | working-directory: ./sample_addin_rs
21 | run: cargo build
22 |
23 | test-macros:
24 |
25 | runs-on: ubuntu-latest
26 |
27 | steps:
28 | - uses: actions/checkout@v3
29 | - name: Install mingw-w64
30 | run: sudo apt-get -y install mingw-w64
31 | - name: Build macros
32 | working-directory: ./
33 | run: cargo test -p native_api_1c_macro
--------------------------------------------------------------------------------
/native_api_1c_macro/tests/trybuild/to_build/functions/int_type.rs:
--------------------------------------------------------------------------------
1 | use std::sync::Arc;
2 |
3 | use native_api_1c::native_api_1c_core::ffi::connection::Connection;
4 | use native_api_1c_macro::AddIn;
5 |
6 | #[derive(AddIn)]
7 | pub struct MyAddIn {
8 | #[add_in_con]
9 | connection: Arc