Skip to content

Commit

Permalink
Merge pull request #248 from koto-lang/rename-core-types
Browse files Browse the repository at this point in the history
Rename the core runtime types
  • Loading branch information
irh authored Oct 11, 2023
2 parents 585b1b6 + b727ad2 commit a225c32
Show file tree
Hide file tree
Showing 57 changed files with 1,127 additions and 1,141 deletions.
7 changes: 5 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,13 @@ The Koto project adheres to
provides access to the VM and its arguments.
- Functions that need access to the `self` instance can access it via
`CallContext::instance`.
- `ValueTuple::data` has been removed, with a `Deref` impl to `&[Value]` taking
- The core Koto runtime types have been renamed for consistency,
and now use a `K` prefix to help disambiguate them in context
(e.g. `KIterator` vs. `Iterator`).
- `KTuple::data` has been removed, with a `Deref` impl to `&[Value]` taking
its place.
- Type strings and strings returned by `KotoFile` implementations are now
expected to be `ValueString`s.
expected to be `KString`s.
- `unexpected_type_error_with_slice` has been renamed to
`type_error_with_slice`, and has had the prefix argument removed.
- `DataMap::get_with_string` has been replaced with a simplified `ValueKey`
Expand Down
4 changes: 2 additions & 2 deletions core/koto/src/koto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ impl Koto {
}

/// Returns a reference to the runtime's prelude
pub fn prelude(&self) -> &ValueMap {
pub fn prelude(&self) -> &KMap {
self.runtime.prelude()
}

/// Returns a reference to the runtime's exports
pub fn exports(&self) -> &ValueMap {
pub fn exports(&self) -> &KMap {
self.runtime.exports()
}

Expand Down
2 changes: 1 addition & 1 deletion core/koto/tests/docs_examples.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ struct OutputCapture {
}

impl KotoFile for OutputCapture {
fn id(&self) -> ValueString {
fn id(&self) -> KString {
"_stdout_".into()
}
}
Expand Down
2 changes: 1 addition & 1 deletion core/koto/tests/repl_mode_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ struct OutputCapture {
}

impl KotoFile for OutputCapture {
fn id(&self) -> ValueString {
fn id(&self) -> KString {
"_stdout_".into()
}
}
Expand Down
20 changes: 10 additions & 10 deletions core/runtime/src/core_lib/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ use std::{
};

/// The initializer for the io module
pub fn make_module() -> ValueMap {
pub fn make_module() -> KMap {
use Value::{Bool, Null, Str};

let result = ValueMap::with_type("core.io");
let result = KMap::with_type("core.io");

result.add_fn("create", {
move |ctx| match ctx.args() {
Expand Down Expand Up @@ -193,11 +193,11 @@ impl KotoType for File {
}

impl KotoObject for File {
fn object_type(&self) -> ValueString {
fn object_type(&self) -> KString {
FILE_TYPE_STRING.with(|t| t.clone())
}

fn copy(&self) -> Object {
fn copy(&self) -> KObject {
self.clone().into()
}

Expand All @@ -213,11 +213,11 @@ impl KotoObject for File {

impl From<File> for Value {
fn from(file: File) -> Self {
Object::from(file).into()
KObject::from(file).into()
}
}

fn file_entries() -> DataMap {
fn file_entries() -> ValueMap {
use Value::*;

ObjectEntryBuilder::<File>::new()
Expand Down Expand Up @@ -276,8 +276,8 @@ fn file_entries() -> DataMap {
}

thread_local! {
static FILE_TYPE_STRING: ValueString = File::TYPE.into();
static FILE_ENTRIES: DataMap = file_entries();
static FILE_TYPE_STRING: KString = File::TYPE.into();
static FILE_ENTRIES: ValueMap = file_entries();
}

struct BufferedSystemFile<T>
Expand All @@ -304,11 +304,11 @@ impl<T> KotoFile for BufferedSystemFile<T>
where
T: Read + Write + Seek,
{
fn id(&self) -> ValueString {
fn id(&self) -> KString {
self.path.to_string_lossy().to_string().into()
}

fn path(&self) -> Result<ValueString> {
fn path(&self) -> Result<KString> {
Ok(self.id())
}

Expand Down
Loading

0 comments on commit a225c32

Please sign in to comment.