Skip to content

Commit

Permalink
feat: linux支持, readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Bylx666 committed Apr 19, 2024
1 parent cf07490 commit 979ee52
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 13 deletions.
3 changes: 3 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[target.x86_64-unknown-linux-musl]
linker = "rust-lld"
rustflags = ["-C", "linker-flavor=ld.lld"]
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
/target
/spec
/samples
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ version = "0.1.6"
edition = "2021"
description = "To be the prettiest and simpliest script"
license = "MPL-2.0"
repository = "https://github.com/bylx666/key-native"
homepage = "https://docs.subkey.top"
documentation = "https://docs.subkey.top/native"
17 changes: 17 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Key Lang

轻快, 省心, 做最精致的编程语言.

1. 消去了引用的存在, 初学者也能轻松上手
2. 更短的循环, `for!`代替`while(true)`
3. 更方便的迭代器, `for i:20`即可循环20次
4. 更强大的`match`, 原生支持数字范围匹配
5. 有趣的`extern`, 用key代码直接操作动态链接库!
6. 区分整数和浮点数, 再也不用`floor`遍地跑
7. 原生类型支持, 动态类型检查, 大量减少判断量
8.`js`一样用`{}`字面量创建哈希表
9. 原生类型`Buf`让你轻松操作内存

更多特性请见[Key语言官网](https://docs.subkey.top).

在我17岁时, 就在只有标准库的情况下完成了整个工程, 并独自创建了[Key语言官网](https://docs.subkey.top)[在线尝试Key语言](https://play.subkey.top/)两个网站. 这一切, 或许都只是我的成人礼罢了.
5 changes: 2 additions & 3 deletions samples/helloworld.ks
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

//mod D:\code\rs\tst\target\debug\tstlib.dll> m;

let s = 99;

log(0b10101010)
let a = 5;
log(`a的值是:{a+5}`);
32 changes: 24 additions & 8 deletions src/c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,34 @@
use std::ptr::NonNull;

extern {
fn LoadLibraryA(src:*const u8)-> *const ();
fn GetProcAddress(lib:*const (), src:*const u8)-> *const ();
#[cfg(windows)]
mod dl {
extern {
fn LoadLibraryA(src:*const u8)-> *const ();
fn GetProcAddress(lib:*const (), src:*const u8)-> *const ();
}
pub unsafe fn dlopen(src:*const u8)-> *const () {
unsafe {LoadLibraryA(src)}
}

pub unsafe fn dlsym(lib:*const (), src:*const u8)-> *const () {
unsafe {GetProcAddress(lib, src)}
}
}

pub unsafe fn dlopen(src:*const u8)-> *const () {
unsafe {LoadLibraryA(src)}
#[cfg(target_os = "linux")]
mod dl {
extern {
#[link_name = "dlopen"]
fn dlopen_(src:*const u8, m:i32)-> *const ();
pub fn dlsym(lib:*const (), src:*const u8)-> *const ();
}
pub unsafe fn dlopen(src:*const u8)-> *const () {
unsafe {dlopen_(src, 0)}
}
}

pub unsafe fn dlsym(lib:*const (), src:*const u8)-> *const () {
unsafe {GetProcAddress(lib, src)}
}
pub use dl::*;


pub struct Clib (*const ());
Expand Down
2 changes: 0 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ static VERSION:usize = 100006;
static DISTRIBUTION:&str = "Subkey";

fn main()-> ExitCode {
// pub use pub mod
// 科学计数法0x 0b
// linux macos支持
// 脚本打包exe

Expand Down

0 comments on commit 979ee52

Please sign in to comment.