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
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "JlrsCore"
uuid = "29be08bc-e5fd-4da2-bbc1-72011c6ea2c9"
authors = ["Thomas van Doornmalen <thomas.vandoornmalen@gmail.com>"]
version = "0.5.0"
version = "0.6.0"

[deps]
JlrsLedger_jll = "946c7259-7191-581b-9320-f4a77977c88e"
Expand Down
27 changes: 13 additions & 14 deletions src/Reflect.jl
Original file line number Diff line number Diff line change
Expand Up @@ -485,19 +485,18 @@ function insertbuiltins!(layouts::IdDict{DataType,Layout})::Nothing
layouts[Char] = BuiltinLayout("::jlrs::data::layout::char::Char", [], false, false, false)
layouts[typeof(Union{})] = BuiltinLayout("::jlrs::data::layout::union::EmptyUnion", [], false, false, false)

layouts[Any] = BuiltinLayout("::jlrs::data::managed::value::ValueRef", [], true, true, true)
layouts[basetype(Array)] = BuiltinLayout("::jlrs::data::managed::array::ArrayRef", [StructParameter(:T, true), StructParameter(:N, true)], true, true, true)
layouts[DataType] = BuiltinLayout("::jlrs::data::managed::datatype::DataTypeRef", [], true, false, true)
layouts[Module] = BuiltinLayout("::jlrs::data::managed::module::ModuleRef", [], true, false, true)
layouts[Core.SimpleVector] = BuiltinLayout("::jlrs::data::managed::simple_vector::SimpleVectorRef", [], true, false, true)
layouts[String] = BuiltinLayout("::jlrs::data::managed::string::StringRef", [], true, false, true)
layouts[Symbol] = BuiltinLayout("::jlrs::data::managed::symbol::SymbolRef", [], true, false, true)
layouts[Task] = BuiltinLayout("::jlrs::data::managed::task::TaskRef", [], true, false, true)
layouts[Core.TypeName] = BuiltinLayout("::jlrs::data::managed::type_name::TypeNameRef", [], true, false, true)
layouts[TypeVar] = BuiltinLayout("::jlrs::data::managed::type_var::TypeVarRef", [], true, false, true)
layouts[Union] = BuiltinLayout("::jlrs::data::managed::union::UnionRef", [], true, false, true)
layouts[UnionAll] = BuiltinLayout("::jlrs::data::managed::union_all::UnionAllRef", [], true, false, true)
layouts[Expr] = BuiltinLayout("::jlrs::data::managed::expr::ExprRef", [], true, false, true)
layouts[Any] = BuiltinLayout("::jlrs::data::managed::value::WeakValue", [], true, true, true)
layouts[basetype(Array)] = BuiltinLayout("::jlrs::data::managed::array::WeakArray", [StructParameter(:T, true), StructParameter(:N, true)], true, true, true)
layouts[DataType] = BuiltinLayout("::jlrs::data::managed::datatype::WeakDataType", [], true, false, true)
layouts[Module] = BuiltinLayout("::jlrs::data::managed::module::WeakModule", [], true, false, true)
layouts[Core.SimpleVector] = BuiltinLayout("::jlrs::data::managed::simple_vector::WeakSimpleVector", [], true, false, true)
layouts[String] = BuiltinLayout("::jlrs::data::managed::string::WeakString", [], true, false, true)
layouts[Symbol] = BuiltinLayout("::jlrs::data::managed::symbol::WeakSymbol", [], true, false, true)
layouts[Core.TypeName] = BuiltinLayout("::jlrs::data::managed::type_name::WeakTypeName", [], true, false, true)
layouts[TypeVar] = BuiltinLayout("::jlrs::data::managed::type_var::WeakTypeVar", [], true, false, true)
layouts[Union] = BuiltinLayout("::jlrs::data::managed::union::WeakUnion", [], true, false, true)
layouts[UnionAll] = BuiltinLayout("::jlrs::data::managed::union_all::WeakUnionAll", [], true, false, true)
layouts[Expr] = BuiltinLayout("::jlrs::data::managed::expr::WeakExpr", [], true, false, true)

layouts[Core.AbstractChar] = BuiltinAbstractLayout()
layouts[Core.AbstractFloat] = BuiltinAbstractLayout()
Expand Down Expand Up @@ -1079,7 +1078,7 @@ function strsignature(layout::StructLayout, field::Union{StructField,TupleField}
wrap_opt = false

if field isa StructField && field.fieldtype isa StructLayout && ismutabletype(field.fieldtype.type)
return "::std::option::Option<::jlrs::data::managed::value::ValueRef<'scope, 'data>>"
return "::std::option::Option<::jlrs::data::managed::value::WeakValue<'scope, 'data>>"
end

if field.fieldtype isa GenericLayout
Expand Down
4 changes: 2 additions & 2 deletions test/AbstractTypes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ end
#[derive(Clone, Debug, Unbox, ValidLayout, Typecheck, ValidField, ConstructType, CCallArg)]
#[jlrs(julia_type = "Main.HasAbstractField")]
pub struct HasAbstractField<'scope, 'data> {
pub a: ::std::option::Option<::jlrs::data::managed::value::ValueRef<'scope, 'data>>,
pub a: ::std::option::Option<::jlrs::data::managed::value::WeakValue<'scope, 'data>>,
}"""
end

Expand All @@ -61,7 +61,7 @@ end
#[derive(Clone, Debug, Unbox, ValidLayout, Typecheck, ValidField, ConstructType, CCallArg)]
#[jlrs(julia_type = "Main.HasAbstractUnionAllField")]
pub struct HasAbstractUnionAllField<'scope, 'data> {
pub a: ::std::option::Option<::jlrs::data::managed::value::ValueRef<'scope, 'data>>,
pub a: ::std::option::Option<::jlrs::data::managed::value::WeakValue<'scope, 'data>>,
}"""
end
end
Expand Down
8 changes: 4 additions & 4 deletions test/Mutable.jl
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ end
#[derive(Clone, Debug, Unbox, ValidLayout, Typecheck, ConstructType)]
#[jlrs(julia_type = "Main.MutNested")]
pub struct MutNested<'scope, 'data> {
pub a: ::std::option::Option<::jlrs::data::managed::value::ValueRef<'scope, 'data>>,
pub a: ::std::option::Option<::jlrs::data::managed::value::WeakValue<'scope, 'data>>,
}"""
end

Expand All @@ -68,7 +68,7 @@ end
#[derive(Clone, Debug, Unbox, ValidLayout, Typecheck, ValidField, ConstructType, CCallArg)]
#[jlrs(julia_type = "Main.Immut")]
pub struct Immut<'scope, 'data> {
pub a: ::std::option::Option<::jlrs::data::managed::value::ValueRef<'scope, 'data>>,
pub a: ::std::option::Option<::jlrs::data::managed::value::WeakValue<'scope, 'data>>,
}"""
end

Expand Down Expand Up @@ -116,7 +116,7 @@ end
#[derive(Clone, Debug, Unbox, ValidLayout, Typecheck, ValidField)]
#[jlrs(julia_type = "Main.HasGenericImmut")]
pub struct HasGenericImmut<'scope, 'data> {
pub a: ::std::option::Option<::jlrs::data::managed::value::ValueRef<'scope, 'data>>,
pub a: ::std::option::Option<::jlrs::data::managed::value::WeakValue<'scope, 'data>>,
}

#[derive(ConstructType, HasLayout)]
Expand All @@ -134,7 +134,7 @@ end
#[derive(Clone, Debug, Unbox, ValidLayout, Typecheck)]
#[jlrs(julia_type = "Main.DoubleHasGeneric")]
pub struct DoubleHasGeneric<'scope, 'data> {
pub a: ::std::option::Option<::jlrs::data::managed::value::ValueRef<'scope, 'data>>,
pub a: ::std::option::Option<::jlrs::data::managed::value::WeakValue<'scope, 'data>>,
}

#[derive(ConstructType, HasLayout)]
Expand Down
2 changes: 1 addition & 1 deletion test/WithBitsUnion.jl
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ end
#[derive(Clone, Debug, Unbox, ValidLayout, Typecheck, ValidField, ConstructType, CCallArg)]
#[jlrs(julia_type = "Main.UnionInTuple")]
pub struct UnionInTuple<'scope, 'data> {
pub a: ::std::option::Option<::jlrs::data::managed::value::ValueRef<'scope, 'data>>,
pub a: ::std::option::Option<::jlrs::data::managed::value::WeakValue<'scope, 'data>>,
}"""
end

Expand Down
68 changes: 26 additions & 42 deletions test/WithBuiltinFields.jl
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@ struct WithSymbol
a::Symbol
end

struct WithTask
a::Task
end

struct WithTypeName
a::Core.TypeName
end
Expand Down Expand Up @@ -79,7 +75,7 @@ end
#[derive(Clone, Debug, Unbox, ValidLayout, Typecheck, ValidField, ConstructType, CCallArg)]
#[jlrs(julia_type = "Main.WithArray")]
pub struct WithArray<'scope, 'data> {
pub a: ::std::option::Option<::jlrs::data::managed::array::ArrayRef<'scope, 'data>>,
pub a: ::std::option::Option<::jlrs::data::managed::array::WeakArray<'scope, 'data>>,
}"""
end

Expand All @@ -91,7 +87,7 @@ end
#[derive(Clone, Debug, Unbox, ValidLayout, Typecheck, ValidField, ConstructType, CCallArg)]
#[jlrs(julia_type = "Main.WithCodeInstance")]
pub struct WithCodeInstance<'scope, 'data> {
pub a: ::std::option::Option<::jlrs::data::managed::value::ValueRef<'scope, 'data>>,
pub a: ::std::option::Option<::jlrs::data::managed::value::WeakValue<'scope, 'data>>,
}"""
end

Expand All @@ -103,7 +99,7 @@ end
#[derive(Clone, Debug, Unbox, ValidLayout, Typecheck, ValidField, ConstructType, CCallArg)]
#[jlrs(julia_type = "Main.WithDataType")]
pub struct WithDataType<'scope> {
pub a: ::std::option::Option<::jlrs::data::managed::datatype::DataTypeRef<'scope>>,
pub a: ::std::option::Option<::jlrs::data::managed::datatype::WeakDataType<'scope>>,
}"""
end

Expand All @@ -115,7 +111,7 @@ end
#[derive(Clone, Debug, Unbox, ValidLayout, Typecheck, ValidField, ConstructType, CCallArg)]
#[jlrs(julia_type = "Main.WithExpr")]
pub struct WithExpr<'scope> {
pub a: ::std::option::Option<::jlrs::data::managed::expr::ExprRef<'scope>>,
pub a: ::std::option::Option<::jlrs::data::managed::expr::WeakExpr<'scope>>,
}"""
end

Expand All @@ -127,7 +123,7 @@ end
#[derive(Clone, Debug, Unbox, ValidLayout, Typecheck, ValidField, ConstructType, CCallArg)]
#[jlrs(julia_type = "Main.WithString")]
pub struct WithString<'scope> {
pub a: ::std::option::Option<::jlrs::data::managed::string::StringRef<'scope>>,
pub a: ::std::option::Option<::jlrs::data::managed::string::WeakString<'scope>>,
}"""
end

Expand All @@ -139,7 +135,7 @@ end
#[derive(Clone, Debug, Unbox, ValidLayout, Typecheck, ValidField, ConstructType, CCallArg)]
#[jlrs(julia_type = "Main.WithMethod")]
pub struct WithMethod<'scope, 'data> {
pub a: ::std::option::Option<::jlrs::data::managed::value::ValueRef<'scope, 'data>>,
pub a: ::std::option::Option<::jlrs::data::managed::value::WeakValue<'scope, 'data>>,
}"""
end

Expand All @@ -151,7 +147,7 @@ end
#[derive(Clone, Debug, Unbox, ValidLayout, Typecheck, ValidField, ConstructType, CCallArg)]
#[jlrs(julia_type = "Main.WithMethodInstance")]
pub struct WithMethodInstance<'scope, 'data> {
pub a: ::std::option::Option<::jlrs::data::managed::value::ValueRef<'scope, 'data>>,
pub a: ::std::option::Option<::jlrs::data::managed::value::WeakValue<'scope, 'data>>,
}"""
end

Expand All @@ -163,7 +159,7 @@ end
#[derive(Clone, Debug, Unbox, ValidLayout, Typecheck, ValidField, ConstructType, CCallArg)]
#[jlrs(julia_type = "Main.WithMethodTable")]
pub struct WithMethodTable<'scope, 'data> {
pub a: ::std::option::Option<::jlrs::data::managed::value::ValueRef<'scope, 'data>>,
pub a: ::std::option::Option<::jlrs::data::managed::value::WeakValue<'scope, 'data>>,
}"""
end

Expand All @@ -175,7 +171,7 @@ end
#[derive(Clone, Debug, Unbox, ValidLayout, Typecheck, ValidField, ConstructType, CCallArg)]
#[jlrs(julia_type = "Main.WithModule")]
pub struct WithModule<'scope> {
pub a: ::std::option::Option<::jlrs::data::managed::module::ModuleRef<'scope>>,
pub a: ::std::option::Option<::jlrs::data::managed::module::WeakModule<'scope>>,
}"""
end

Expand All @@ -187,7 +183,7 @@ end
#[derive(Clone, Debug, Unbox, ValidLayout, Typecheck, ValidField, ConstructType, CCallArg)]
#[jlrs(julia_type = "Main.WithSimpleVector")]
pub struct WithSimpleVector<'scope> {
pub a: ::std::option::Option<::jlrs::data::managed::simple_vector::SimpleVectorRef<'scope>>,
pub a: ::std::option::Option<::jlrs::data::managed::simple_vector::WeakSimpleVector<'scope>>,
}"""
end

Expand All @@ -199,19 +195,7 @@ end
#[derive(Clone, Debug, Unbox, ValidLayout, Typecheck, ValidField, ConstructType, CCallArg)]
#[jlrs(julia_type = "Main.WithSymbol")]
pub struct WithSymbol<'scope> {
pub a: ::std::option::Option<::jlrs::data::managed::symbol::SymbolRef<'scope>>,
}"""
end

@test begin
b = Reflect.reflect([WithTask])
sb = Reflect.StringLayouts(b)

sb[WithTask] === """#[repr(C)]
#[derive(Clone, Debug, Unbox, ValidLayout, Typecheck, ValidField, ConstructType, CCallArg)]
#[jlrs(julia_type = "Main.WithTask")]
pub struct WithTask<'scope> {
pub a: ::std::option::Option<::jlrs::data::managed::task::TaskRef<'scope>>,
pub a: ::std::option::Option<::jlrs::data::managed::symbol::WeakSymbol<'scope>>,
}"""
end

Expand All @@ -223,7 +207,7 @@ end
#[derive(Clone, Debug, Unbox, ValidLayout, Typecheck, ValidField, ConstructType, CCallArg)]
#[jlrs(julia_type = "Main.WithTypeMapEntry")]
pub struct WithTypeMapEntry<'scope, 'data> {
pub a: ::std::option::Option<::jlrs::data::managed::value::ValueRef<'scope, 'data>>,
pub a: ::std::option::Option<::jlrs::data::managed::value::WeakValue<'scope, 'data>>,
}"""
end

Expand All @@ -235,7 +219,7 @@ end
#[derive(Clone, Debug, Unbox, ValidLayout, Typecheck, ValidField, ConstructType, CCallArg)]
#[jlrs(julia_type = "Main.WithTypeMapLevel")]
pub struct WithTypeMapLevel<'scope, 'data> {
pub a: ::std::option::Option<::jlrs::data::managed::value::ValueRef<'scope, 'data>>,
pub a: ::std::option::Option<::jlrs::data::managed::value::WeakValue<'scope, 'data>>,
}"""
end

Expand All @@ -247,7 +231,7 @@ end
#[derive(Clone, Debug, Unbox, ValidLayout, Typecheck, ValidField, ConstructType, CCallArg)]
#[jlrs(julia_type = "Main.WithTypeName")]
pub struct WithTypeName<'scope> {
pub a: ::std::option::Option<::jlrs::data::managed::type_name::TypeNameRef<'scope>>,
pub a: ::std::option::Option<::jlrs::data::managed::type_name::WeakTypeName<'scope>>,
}"""
end

Expand All @@ -259,7 +243,7 @@ end
#[derive(Clone, Debug, Unbox, ValidLayout, Typecheck, ValidField, ConstructType, CCallArg)]
#[jlrs(julia_type = "Main.WithTypeVar")]
pub struct WithTypeVar<'scope> {
pub a: ::std::option::Option<::jlrs::data::managed::type_var::TypeVarRef<'scope>>,
pub a: ::std::option::Option<::jlrs::data::managed::type_var::WeakTypeVar<'scope>>,
}"""
end

Expand All @@ -271,7 +255,7 @@ end
#[derive(Clone, Debug, Unbox, ValidLayout, Typecheck, ValidField, ConstructType, CCallArg)]
#[jlrs(julia_type = "Main.WithUnion")]
pub struct WithUnion<'scope> {
pub a: ::std::option::Option<::jlrs::data::managed::union::UnionRef<'scope>>,
pub a: ::std::option::Option<::jlrs::data::managed::union::WeakUnion<'scope>>,
}"""
end

Expand All @@ -283,7 +267,7 @@ end
#[derive(Clone, Debug, Unbox, ValidLayout, Typecheck, ValidField, ConstructType, CCallArg)]
#[jlrs(julia_type = "Main.WithUnionAll")]
pub struct WithUnionAll<'scope> {
pub a: ::std::option::Option<::jlrs::data::managed::union_all::UnionAllRef<'scope>>,
pub a: ::std::option::Option<::jlrs::data::managed::union_all::WeakUnionAll<'scope>>,
}"""
end

Expand All @@ -295,7 +279,7 @@ end
#[derive(Clone, Debug, Unbox, ValidLayout, Typecheck, ValidField, ConstructType, CCallArg)]
#[jlrs(julia_type = "Main.WithCodeInstance")]
pub struct WithCodeInstance<'scope, 'data> {
pub a: ::std::option::Option<::jlrs::data::managed::value::ValueRef<'scope, 'data>>,
pub a: ::std::option::Option<::jlrs::data::managed::value::WeakValue<'scope, 'data>>,
}"""
end

Expand All @@ -307,7 +291,7 @@ end
#[derive(Clone, Debug, Unbox, ValidLayout, Typecheck, ValidField, ConstructType, CCallArg)]
#[jlrs(julia_type = "Main.WithArray")]
pub struct WithArray<'scope, 'data> {
pub a: ::std::option::Option<::jlrs::data::managed::array::ArrayRef<'scope, 'data>>,
pub a: ::std::option::Option<::jlrs::data::managed::array::WeakArray<'scope, 'data>>,
}"""
end

Expand All @@ -321,7 +305,7 @@ end
#[derive(Clone, Debug, Unbox, ValidLayout, Typecheck, ValidField, ConstructType, CCallArg)]
#[jlrs(julia_type = "Main.WithDataType")]
pub struct WithDataType<'scope> {
pub a: ::std::option::Option<::jlrs::data::managed::datatype::DataTypeRef<'scope>>,
pub a: ::std::option::Option<::jlrs::data::managed::datatype::WeakDataType<'scope>>,
}"""
end

Expand All @@ -333,7 +317,7 @@ end
#[derive(Clone, Debug, Unbox, ValidLayout, Typecheck, ValidField, ConstructType, CCallArg)]
#[jlrs(julia_type = "Main.WithExpr")]
pub struct WithExpr<'scope> {
pub a: ::std::option::Option<::jlrs::data::managed::expr::ExprRef<'scope>>,
pub a: ::std::option::Option<::jlrs::data::managed::expr::WeakExpr<'scope>>,
}"""
end

Expand All @@ -345,7 +329,7 @@ end
#[derive(Clone, Debug, Unbox, ValidLayout, Typecheck, ValidField, ConstructType, CCallArg)]
#[jlrs(julia_type = "Main.WithMethod")]
pub struct WithMethod<'scope, 'data> {
pub a: ::std::option::Option<::jlrs::data::managed::value::ValueRef<'scope, 'data>>,
pub a: ::std::option::Option<::jlrs::data::managed::value::WeakValue<'scope, 'data>>,
}"""
end

Expand All @@ -357,7 +341,7 @@ end
#[derive(Clone, Debug, Unbox, ValidLayout, Typecheck, ValidField, ConstructType, CCallArg)]
#[jlrs(julia_type = "Main.WithMethodInstance")]
pub struct WithMethodInstance<'scope, 'data> {
pub a: ::std::option::Option<::jlrs::data::managed::value::ValueRef<'scope, 'data>>,
pub a: ::std::option::Option<::jlrs::data::managed::value::WeakValue<'scope, 'data>>,
}"""
end

Expand All @@ -369,7 +353,7 @@ end
#[derive(Clone, Debug, Unbox, ValidLayout, Typecheck, ValidField, ConstructType, CCallArg)]
#[jlrs(julia_type = "Main.WithMethodTable")]
pub struct WithMethodTable<'scope, 'data> {
pub a: ::std::option::Option<::jlrs::data::managed::value::ValueRef<'scope, 'data>>,
pub a: ::std::option::Option<::jlrs::data::managed::value::WeakValue<'scope, 'data>>,
}"""
end

Expand All @@ -381,7 +365,7 @@ end
#[derive(Clone, Debug, Unbox, ValidLayout, Typecheck, ValidField, ConstructType, CCallArg)]
#[jlrs(julia_type = "Main.WithTypeMapEntry")]
pub struct WithTypeMapEntry<'scope, 'data> {
pub a: ::std::option::Option<::jlrs::data::managed::value::ValueRef<'scope, 'data>>,
pub a: ::std::option::Option<::jlrs::data::managed::value::WeakValue<'scope, 'data>>,
}"""
end

Expand All @@ -393,7 +377,7 @@ end
#[derive(Clone, Debug, Unbox, ValidLayout, Typecheck, ValidField, ConstructType, CCallArg)]
#[jlrs(julia_type = "Main.WithTypeMapLevel")]
pub struct WithTypeMapLevel<'scope, 'data> {
pub a: ::std::option::Option<::jlrs::data::managed::value::ValueRef<'scope, 'data>>,
pub a: ::std::option::Option<::jlrs::data::managed::value::WeakValue<'scope, 'data>>,
}"""
end
end
Loading
Loading