Some arg Fun in Rust. (0.38.1)
This commit is contained in:
parent
87833b0c1e
commit
543483041b
16 changed files with 167 additions and 66 deletions
|
|
@ -33,9 +33,9 @@ if len(readers) > 0
|
|||
|
||||
if h != 0
|
||||
// Sample APDU: SELECT MF (00 A4 00 00 02 3F 00)
|
||||
resp = pc.transmit_hex(h, "00A40000023F00")
|
||||
// Print hex data and SW
|
||||
print("resp.data_hex=" + resp["data_hex"])
|
||||
// Use the safe convenience transmitter which returns a map {data, sw1, sw2, code}
|
||||
resp = pc.transmit("00A40000023F00")
|
||||
print("resp.data.len=" + to_string(len(resp["data"])) + " bytes")
|
||||
print("resp.sw1=" + to_string(resp["sw1"]) + " sw2=" + to_string(resp["sw2"]) + " code=" + to_string(resp["code"]))
|
||||
|
||||
_ = pc.disconnect(h)
|
||||
|
|
|
|||
|
|
@ -30,3 +30,7 @@
|
|||
*/
|
||||
|
||||
print(rust_hello())
|
||||
|
||||
/* Expected output:
|
||||
Hello from Rust ops!
|
||||
*/
|
||||
|
|
|
|||
37
examples/rust_hello_args.fun
Executable file
37
examples/rust_hello_args.fun
Executable file
|
|
@ -0,0 +1,37 @@
|
|||
#!/usr/bin/env fun
|
||||
|
||||
/*
|
||||
* This file is part of the Fun programming language.
|
||||
* https://fun-lang.xyz/
|
||||
*
|
||||
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||
* Licensed under the terms of the Apache-2.0 license.
|
||||
* https://opensource.org/license/apache-2-0
|
||||
*
|
||||
* Added: 2026-01-28
|
||||
*/
|
||||
|
||||
/*
|
||||
* Rust-backed opcode demo with argument: rust_hello_args(STRING)
|
||||
*
|
||||
* Build instructions:
|
||||
* - Rust integration is optional. Enable via:
|
||||
* cmake -S . -B build_debug -DFUN_WITH_RUST=ON
|
||||
* - Then build:
|
||||
* cmake --build build_debug --target fun
|
||||
*
|
||||
* Run:
|
||||
* build_debug/fun examples/rust_hello_args.fun
|
||||
*
|
||||
* Expected output (with FUN_WITH_RUST=ON):
|
||||
* Hello from Fun to Rust!
|
||||
*
|
||||
* Note:
|
||||
* The opcode prints from Rust and returns Nil, so there's nothing to print afterwards.
|
||||
*/
|
||||
|
||||
rust_hello_args("Hello from Fun to Rust!")
|
||||
|
||||
/* Expected output:
|
||||
Hello from Fun to Rust!
|
||||
*/
|
||||
Loading…
Add table
Add a link
Reference in a new issue