From 5df7a32a7f31efae53019c831bebbfff8609f24e Mon Sep 17 00:00:00 2001 From: Qrakhen Date: Fri, 8 May 2026 06:47:01 +0200 Subject: [PATCH] fix readme and remove unrelated library, no idea how it got here --- Qrakhen.Qamp.Core/Execution/Runner.cs | 4 +- Qrakhen.TilingFrames/AssemblyInfo.cs | 10 -- .../Qrakhen.TilingFrames.csproj | 14 --- Qrakhen.TilingFrames/README.md | 49 ---------- README.md | 94 ++++++++++++++++--- 5 files changed, 83 insertions(+), 88 deletions(-) delete mode 100644 Qrakhen.TilingFrames/AssemblyInfo.cs delete mode 100644 Qrakhen.TilingFrames/Qrakhen.TilingFrames.csproj delete mode 100644 Qrakhen.TilingFrames/README.md diff --git a/Qrakhen.Qamp.Core/Execution/Runner.cs b/Qrakhen.Qamp.Core/Execution/Runner.cs index 67ff007..553776d 100644 --- a/Qrakhen.Qamp.Core/Execution/Runner.cs +++ b/Qrakhen.Qamp.Core/Execution/Runner.cs @@ -712,7 +712,9 @@ public class Runner : IDisposable } if (value.Is(T.Native)) { - return InvokeNative(value.Ptr.As(), argumentCount); + if (value.Ptr.As() is NativeFunction native) + return InvokeNative(native, argumentCount); + return false; // unlikely edge case, natives are always set directly via the global registry } else if (value.Is(T.Method)) { Method method = value.Ptr.As()!; _stack.Set(_cursor - method.Function.ArgumentCount - 1, method.Receiver); diff --git a/Qrakhen.TilingFrames/AssemblyInfo.cs b/Qrakhen.TilingFrames/AssemblyInfo.cs deleted file mode 100644 index b0ec827..0000000 --- a/Qrakhen.TilingFrames/AssemblyInfo.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System.Windows; - -[assembly: ThemeInfo( - ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located - //(used if a resource is not found in the page, - // or application resource dictionaries) - ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located - //(used if a resource is not found in the page, - // app, or any theme specific resource dictionaries) -)] diff --git a/Qrakhen.TilingFrames/Qrakhen.TilingFrames.csproj b/Qrakhen.TilingFrames/Qrakhen.TilingFrames.csproj deleted file mode 100644 index 62bbe54..0000000 --- a/Qrakhen.TilingFrames/Qrakhen.TilingFrames.csproj +++ /dev/null @@ -1,14 +0,0 @@ - - - - net8.0-windows - enable - true - enable - - - - - - - diff --git a/Qrakhen.TilingFrames/README.md b/Qrakhen.TilingFrames/README.md deleted file mode 100644 index dbd3d32..0000000 --- a/Qrakhen.TilingFrames/README.md +++ /dev/null @@ -1,49 +0,0 @@ -# TilingFrames -## Tiling (Docking) window manager library for WPF -### Qrakhen.TilingFramess - -Cool Library to have tiling panels. -Is that not cool? -I think it very much is cool. -Very nice, yes. Alpha & Beta. No Gamma or Delta. Just Alpha-Beta. - -Data structure resembles a binary tree with uniform branch- and end-nodes (TilingPanels & TilingHosts). - -### Node - -### Panel - -### Host - -### Frame - -### Window - -### Node Structure -```cs - RootPanel - / \ - A B - / \ - Panel Host - / \ |-Frame (Single Frame) - / \ - Panel Host - / \ |-Frame (Tab) - / . |-Frame (Tab) - Host - |-Frame (Tab) - |-Frame (Tab) - |-Frame (Tab) -``` -Key Behaviours: - - All Panels have information about how and where their content is split in two. - - Every panel may have up to two children (Alpha/Beta), where Alpha is never null. - - Beta may not be set (In a case of a single frame with no splits, for example). - - If a child located at Alpha is detached, Beta will move to alpha, to ensure the 'Alpha is always set' paradigm. - - If a child is detached and both alpha and beta result in being null, the entire Panel is detached from its parent. - - Hosts are always at the end of the branches, everything above a Node is a Panel. - - The things you're dragging around to re-order, separate and split panels are Frames. - - Hosts contain Frames, which will be displayed as tabs if stacked atop each other, or as a single frame if only one is present. - - All mutations of the tree structure expect the root node as their first argument. - That is done so there's no two-way referencing and to keep stuff simple. \ No newline at end of file diff --git a/README.md b/README.md index abafb6c..1ec3ffb 100644 --- a/README.md +++ b/README.md @@ -91,25 +91,91 @@ which should be located within your `./Build/` folder after building as describe Here's a quick example of how you would implement virtually any library: ```cs using Qrakhen.Qamp.Core; -using System.Math; -Value Sqrt(Value number) +// This is an intentionally bad implementation of a linked list. +[ExportType("llist")] +public class LinkedListNode : Obj { - Assert.IsNumber(number); + [HideProperty] + public LinkedListNode? Next { get; private set; } - if (number.IsDecimal) - return Math.Sqrt(number.AsDecimal); - if (number.IsSigned) - return Math.Sqrt(number.AsSigned); - if (number.IsUnsigned) - return Math.Sqrt(number.Unsigned); - throw new Qrakhen.Qamp.Core.QampException($"Unsupported value type {value}"); + public Value Value { get; private set; } + + public LinkedList(Value value) { + // ...internal setup + this.Value = value; + } + + // Q& constructors, if needed, have to be explicitely declared to return a value type. + [ExportConstructor] + public static Value Ctor(params Value[] args) { + current = this; + while (current.Next != null) + current = current.Next; + + // This simply returns a new pointer to an already existing + // oject inside the heap, rather than actually create a new one. + // It wraps a pointer to the provided object inside a value that + // has the 'Ptr' type flag, passing it to the Q& runtime. + return Obj.Create(current); + } + + // Tell the type mapper to export this method + [ExportMethod] + public Value Last() { + // This simply returns a new pointer to an already existing type. + // The call ddoes not actually create a new object. + var current = this; + while (current.Next != null) { + current = current.Next; + return Obj.Create(); + } + + // Value is the base type of anything in Q&. + // An object is just a value of type 'Ptr' (value.IsPtr), + // and primitives have their value stored in the 8 byte + // buffer of the value itself (value.Data). + [ExportMethod] + public void Add(Value value) { + var current = this; + while (current.Next != null) + current = current.Next; + current.Next = new LinkedList(value); + } + + // Methods that accept a primitive will automatically try + // retrieve that type from the provided arguments as Values. + // You may always simply declare to accept Values aswell, + // which gives you some dynamic flexibility if needed. + [ExportMethod] + public Value? GetItem(long index) { + long current = 0; + var node = this; + while (current < index) { + current++; + node = node.Next; + } + return node; + } } - -Injector injector = new(); -injector.Register(scope: Scope.Global, name: "sqrt", params: [ ("number", ValueType.Number) ], returns: ValueType.Number); -injector.Export("desiredPath.sqi"); ``` + +You may manually register all types inside an assembly by calling +``` + Library:Load("mylib.dll"); +``` +directly in Q&. +Usage of the type described above would look somewhat like this: +``` + *~ list = new llist(); + list.Add(5); + list.Add('test'); + list.Add([1, 2, 3]); + print(list.GetItem(1)); // 'test' + print(list.Last()); // [ 1, 2, 3 ] + *~ protected = list.Value; // will throw an exception, as we did not expose that property. +``` + That's it - although this being a very simple example, more is possible. I will add a few basic implementations of very common libraries in a separate repository soon.