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
38 changes: 38 additions & 0 deletions cpp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,30 @@ mod ffi {
pub examples: Vec<HashMapExampleValue>,
/// Base schema if applicable.
pub base_schema: OptionalKclType,
/// Function type if the KclType is a function.
pub function: OptionalFunctionType,
/// Optional schema index signature
pub index_signature: OptionalIndexSignature,
}

#[derive(Debug, Default)]
pub struct FunctionType {
pub params: Vec<Parameter>,
pub return_ty: OptionalKclType,
}

#[derive(Debug, Default)]
pub struct Parameter {
pub name: String,
pub ty: OptionalKclType,
}

#[derive(Debug, Default)]
pub struct IndexSignature {
pub key_name: String,
pub key: OptionalKclType,
pub val: OptionalKclType,
pub any_other: bool,
}

#[derive(Debug, Default)]
Expand All @@ -674,6 +698,18 @@ mod ffi {
value: String,
}

#[derive(Debug, Default)]
struct OptionalFunctionType {
has_value: bool,
value: FunctionType,
}

#[derive(Debug, Default)]
struct OptionalIndexSignature {
has_value: bool,
value: IndexSignature,
}

#[derive(Debug, Default)]
/// Message representing a decorator in KCL.
pub struct Decorator {
Expand Down Expand Up @@ -1340,6 +1376,8 @@ impl KclType {
pkg_path: r.pkg_path.clone(),
line: r.line,
item: OptionalKclType::new_from_box(&r.item),
// TODO: function and index_signature fields
..Default::default()
}
}
}
Expand Down
20 changes: 20 additions & 0 deletions nodejs/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,26 @@ export interface KclType {
description: string
/** A map object to hold examples, the key is the example name. */
examples: Record<string, Example>
/** Base schema if applicable. */
baseSchema: KclType
/** Function type if the KclType is a function. */
function: FunctionType
/** Optional schema index signature */
indexSignature?: IndexSignature
}
export interface FunctionType {
params: Array<Parameter>
returnTy: KclType
}
export interface Parameter {
name: string
ty: KclType
}
export interface IndexSignature {
keyName?: string
key: KclType
val: KclType
anyOther: boolean
}
/** Message representing a decorator in KCL. */
export interface Decorator {
Expand Down
26 changes: 26 additions & 0 deletions nodejs/src/spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,32 @@ pub struct KclType {
pub description: String,
/// A map object to hold examples, the key is the example name.
pub examples: HashMap<String, Example>,
/// Base schema if applicable.
pub base_schema: Reference<KclType>,
/// Function type if the KclType is a function.
pub function: FunctionType,
/// Optional schema index signature
pub index_signature: Option<IndexSignature>,
}

#[napi(object)]
pub struct FunctionType {
pub params: Vec<Parameter>,
pub return_ty: Reference<KclType>,
}

#[napi(object)]
pub struct Parameter {
pub name: String,
pub ty: Reference<KclType>,
}

#[napi(object)]
pub struct IndexSignature {
pub key_name: Option<String>,
pub key: Reference<KclType>,
pub val: Reference<KclType>,
pub any_other: bool,
}

/// Message representing a decorator in KCL.
Expand Down
1 change: 1 addition & 0 deletions swift/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ DerivedData/
/KclLib/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
/KclLib/.swiftpm/config/registries.json
/KclLib/Sources/CKclLib/lib
Cargo.lock
Loading
Loading