Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "kcl-lang"
version = "0.8.3"
version = "0.8.4"
edition = "2021"
readme = "README.md"
documentation = "kcl-lang.io"
Expand All @@ -10,10 +10,5 @@ license = "Apache-2.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
prost = "0.11.8"
prost-types = "0.11.8"
serde_json = "1"
anyhow = "1"
serde = { version = "1", features = ["derive"] }
libloading = "0.7.3"
tempfile = "3.5.0"
kclvm-api = { git = "https://github.com/kcl-lang/kcl", version = "0.8.4" }
10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
# KCL Artifact Library for SDKs
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fkcl-lang%2Flib.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Fkcl-lang%2Flib?ref=badge_shield)


This repo mainly includes the binding of the low-level API and spec of the [KCL language core](https://github.com/kcl-lang/kcl), and the SDKs of various languages are based on this to encapsulate higher-level APIs.

## Rust

```shell
cargo add --git https://github.com/kcl-lang/lib kcl-lang
cargo add --git https://github.com/kcl-lang/lib
```

Write the Code
Expand All @@ -17,7 +15,7 @@ use kcl_lang::*;
use anyhow::Result;

fn main() -> Result<()> {
let api = API::new()?;
let api = API::default();
let args = &ExecProgramArgs {
k_filename_list: vec!["main.k".to_string()],
k_code_list: vec!["a = 1".to_string()],
Expand Down Expand Up @@ -71,6 +69,6 @@ result = api.exec_program(args)
print(result.yaml_result)
```


## License
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fkcl-lang%2Flib.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2Fkcl-lang%2Flib?ref=badge_large)

[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fkcl-lang%2Flib.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2Fkcl-lang%2Flib?ref=badge_large)
2 changes: 1 addition & 1 deletion install.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"runtime"
)

const KCLVM_VERSION = "v0.8.3"
const KCLVM_VERSION = "v0.8.4"

func findPath(name string) string {
if path, err := exec.LookPath(name); err == nil {
Expand Down
2 changes: 1 addition & 1 deletion java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.kcl</groupId>
<artifactId>kcl-lib</artifactId>
<version>0.8.3</version>
<version>0.8.4</version>
<name>KCL Arifact Library for Java</name>
<description>
KCL is an open-source constraint-based record and functional language mainly
Expand Down
7 changes: 2 additions & 5 deletions java/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use anyhow::Result;
use jni::objects::{JByteArray, JClass, JObject};
use jni::sys::jbyteArray;
use jni::JNIEnv;
use kcl_lang::API;
use kcl_lang::call;
use kclvm_api::gpyrpc::LoadPackageArgs;
use kclvm_api::service::KclvmServiceImpl;
use kclvm_parser::KCLModuleCache;
Expand All @@ -23,7 +23,6 @@ use prost::Message;
use std::sync::Mutex;

lazy_static! {
static ref API_INSTANCE: Mutex<OnceCell<API>> = Mutex::new(OnceCell::new());
static ref MODULE_CACHE: Mutex<OnceCell<KCLModuleCache>> = Mutex::new(OnceCell::new());
static ref SCOPE_CACHE: Mutex<OnceCell<KCLScopeCache>> = Mutex::new(OnceCell::new());
}
Expand Down Expand Up @@ -54,11 +53,9 @@ pub extern "system" fn Java_com_kcl_api_API_loadPackageWithCache(
}

fn intern_call_native(env: &mut JNIEnv, name: JByteArray, args: JByteArray) -> Result<jbyteArray> {
let binding = API_INSTANCE.lock().unwrap();
let api = binding.get_or_init(|| kcl_lang::API::new().expect("Failed to create API instance"));
let name = env.convert_byte_array(name)?;
let args = env.convert_byte_array(args)?;
let result = api.call_native(&name, &args)?;
let result = call(&name, &args)?;
let j_byte_array = env.byte_array_from_slice(&result)?;
Ok(j_byte_array.into_raw())
}
Expand Down
Loading