Skip to content

Commit

Permalink
Add clAsString.
Browse files Browse the repository at this point in the history
  • Loading branch information
fubark committed Sep 2, 2024
1 parent 0d38c46 commit 4f2ca7e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/capi.zig
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ pub fn symbol(vm: *ZVM, str: []const u8) Value {
return c.clSymbol(@ptrCast(vm), toStr(str));
}
pub const asSymbolId = c.clAsSymbolId;
pub fn asString(val: Value) []const u8 {
return fromStr(c.clAsString(val));
}
pub const clTrue = c.clTrue;
pub const clFalse = c.clFalse;
pub const asBoxInt = c.clAsBoxInt;
Expand Down
1 change: 1 addition & 0 deletions src/include/cyber.h
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,7 @@ CLStr clNewValueDump(CLVM* vm, CLValue val);
double clAsFloat(CLValue val);
bool clToBool(CLValue val);
bool clAsBool(CLValue val);
CLStr clAsString(CLValue val);
int64_t clAsBoxInt(CLValue val);
uint32_t clAsSymbolId(CLValue val);
CLStr clToTempString(CLVM* vm, CLValue val);
Expand Down
4 changes: 4 additions & 0 deletions src/lib.zig
Original file line number Diff line number Diff line change
Expand Up @@ -751,6 +751,10 @@ test "clAsBoxInt()" {
try t.eq(c.asBoxInt(val), 123);
}

export fn clAsString(val: cy.Value) c.Str {
return c.toStr(val.asString());
}

export fn clAsSymbolId(val: Value) u32 {
return val.asSymbolId();
}
Expand Down

0 comments on commit 4f2ca7e

Please sign in to comment.