From dee3033007ab6e0e88ed32fa79cd8888f3478967 Mon Sep 17 00:00:00 2001 From: Hatter Jiang Date: Sun, 10 Jan 2021 15:10:53 +0800 Subject: [PATCH] feat: add dota lib --- __misc/dotalib/Cargo.lock | 5 ++ __misc/dotalib/Cargo.toml | 13 +++ __misc/dotalib/README.md | 14 ++++ __misc/dotalib/cbindgen.toml | 151 +++++++++++++++++++++++++++++++++++ __misc/dotalib/dotalib.h | 8 ++ __misc/dotalib/src/lib.rs | 4 + 6 files changed, 195 insertions(+) create mode 100644 __misc/dotalib/Cargo.lock create mode 100644 __misc/dotalib/Cargo.toml create mode 100644 __misc/dotalib/README.md create mode 100644 __misc/dotalib/cbindgen.toml create mode 100644 __misc/dotalib/dotalib.h create mode 100644 __misc/dotalib/src/lib.rs diff --git a/__misc/dotalib/Cargo.lock b/__misc/dotalib/Cargo.lock new file mode 100644 index 0000000..19519b7 --- /dev/null +++ b/__misc/dotalib/Cargo.lock @@ -0,0 +1,5 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "dotalib" +version = "0.1.0" diff --git a/__misc/dotalib/Cargo.toml b/__misc/dotalib/Cargo.toml new file mode 100644 index 0000000..ac177ca --- /dev/null +++ b/__misc/dotalib/Cargo.toml @@ -0,0 +1,13 @@ +[package] +name = "dotalib" +version = "0.1.0" +authors = ["Hatter Jiang "] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[lib] +name = "dotalib" +crate-type = ["staticlib"] + +[dependencies] diff --git a/__misc/dotalib/README.md b/__misc/dotalib/README.md new file mode 100644 index 0000000..aa9dd17 --- /dev/null +++ b/__misc/dotalib/README.md @@ -0,0 +1,14 @@ + +cbindgen: +https://github.com/eqrion/cbindgen + +C++ +```shell +cbindgen --config cbindgen.toml --crate dotalib --output dotalib.h +``` + +C +```shell +cbindgen --config cbindgen.toml --crate dotalib --lang c --output dotalib.h +``` + diff --git a/__misc/dotalib/cbindgen.toml b/__misc/dotalib/cbindgen.toml new file mode 100644 index 0000000..30ecf57 --- /dev/null +++ b/__misc/dotalib/cbindgen.toml @@ -0,0 +1,151 @@ +# This is a template cbindgen.toml file with all of the default values. +# Some values are commented out because their absence is the real default. +# +# See https://github.com/eqrion/cbindgen/blob/master/docs.md#cbindgentoml +# for detailed documentation of every option here. + + + +language = "C++" + + + +############## Options for Wrapping the Contents of the Header ################# + +# header = "/* Text to put at the beginning of the generated file. Probably a license. */" +# trailer = "/* Text to put at the end of the generated file */" +# include_guard = "my_bindings_h" +# pragma_once = true +# autogen_warning = "/* Warning, this file is autogenerated by cbindgen. Don't modify this manually. */" +include_version = false +# namespace = "my_namespace" +namespaces = [] +using_namespaces = [] +sys_includes = [] +includes = [] +no_includes = false +after_includes = "" + + + + +############################ Code Style Options ################################ + +braces = "SameLine" +line_length = 100 +tab_width = 2 +documentation_style = "auto" +line_endings = "LF" # also "CR", "CRLF", "Native" + + + + +############################# Codegen Options ################################## + +style = "both" +sort_by = "Name" # default for `fn.sort_by` and `const.sort_by` +usize_is_size_t = true + + + +[defines] +# "target_os = freebsd" = "DEFINE_FREEBSD" +# "feature = serde" = "DEFINE_SERDE" + + + +[export] +include = [] +exclude = [] +# prefix = "CAPI_" +item_types = [] +renaming_overrides_prefixing = false + + + +[export.rename] + + + +[export.body] + + +[export.mangle] + + +[fn] +rename_args = "None" +# must_use = "MUST_USE_FUNC" +# no_return = "NO_RETURN" +# prefix = "START_FUNC" +# postfix = "END_FUNC" +args = "auto" +sort_by = "Name" + + + + +[struct] +rename_fields = "None" +# must_use = "MUST_USE_STRUCT" +derive_constructor = false +derive_eq = false +derive_neq = false +derive_lt = false +derive_lte = false +derive_gt = false +derive_gte = false + + + + +[enum] +rename_variants = "None" +# must_use = "MUST_USE_ENUM" +add_sentinel = false +prefix_with_name = false +derive_helper_methods = false +derive_const_casts = false +derive_mut_casts = false +# cast_assert_name = "ASSERT" +derive_tagged_enum_destructor = false +derive_tagged_enum_copy_constructor = false +enum_class = true +private_default_tagged_enum_constructor = false + + + + +[const] +allow_static_const = true +allow_constexpr = false +sort_by = "Name" + + + + +[macro_expansion] +bitflags = false + + + + + + +############## Options for How Your Rust library Should Be Parsed ############## + +[parse] +parse_deps = false +# include = [] +exclude = [] +clean = false +extra_bindings = [] + + + +[parse.expand] +crates = [] +all_features = false +default_features = true +features = [] + diff --git a/__misc/dotalib/dotalib.h b/__misc/dotalib/dotalib.h new file mode 100644 index 0000000..f96ab1d --- /dev/null +++ b/__misc/dotalib/dotalib.h @@ -0,0 +1,8 @@ +#include +#include +#include +#include +#include + + +void print_hello_world(void); diff --git a/__misc/dotalib/src/lib.rs b/__misc/dotalib/src/lib.rs new file mode 100644 index 0000000..6fa6b6c --- /dev/null +++ b/__misc/dotalib/src/lib.rs @@ -0,0 +1,4 @@ +#[no_mangle] +pub unsafe extern "C" fn print_hello_world() { + println!("Hello World!"); +}