From e971e5838a4e1135b40abe94e372ef1abe5c9bc3 Mon Sep 17 00:00:00 2001 From: Mike Nolan Date: Wed, 22 Oct 2025 20:53:27 -0500 Subject: [PATCH] Add types --- content/runtime/getargument.md | 100 +++++++++++++++++++++++++++++++++ content/runtime/types.md | 21 +++++++ 2 files changed, 121 insertions(+) create mode 100644 content/runtime/getargument.md create mode 100644 content/runtime/types.md diff --git a/content/runtime/getargument.md b/content/runtime/getargument.md new file mode 100644 index 0000000..a283ce4 --- /dev/null +++ b/content/runtime/getargument.md @@ -0,0 +1,100 @@ ++++ +title = 'Get Argument Helpers' +date = 2025-10-22T20:31:08-05:00 ++++ + +## GetArgument +```c++ +/* + Gets a non heap object from arguments + Returns true if argument is of type T and index < args.size() + obj is set to the args[index] if it returns true +*/ +template +bool GetArgument(std::vector& args, size_t index, T& obj); +``` + +```c++ +//Heres it in code +static TObject My_Custom(GCList& ls, std::vector args) +{ + int64_t n; + if(GetArgument(args,0,n)) + { + return n + 5; + } + return (int64_t)5; +} +``` +## GetArgumentHeap + +```c++ +/* + Gets a heap object from arguments + Returns true if argument is of type T and index < args.size() + obj is set to the args[index] if it returns true +*/ +template +bool GetArgumentHeap(std::vector& args, size_t index, T& obj); +``` + +```c++ +//Heres it in code +static TObject My_Custom(GCList& ls, std::vector args) +{ + TList* list; + if(GetArgumentHeap(args,0,list)) + { + list->Add((std::string)"Hello, world"); + } + return nullptr; +} +```c++ + +/* + Gets a non heap object from src + Returns true if argument is of type T + obj is set to src if it returns true +*/ +template +bool GetObject(TObject& src, T& obj); +``` + +```c++ +//Heres it in code +static TObject My_Custom(GCList& ls, std::vector args) +{ + int64_t n; + TDictionary* dict; + if(GetArgumentHeap(args,0,dict)) + { + auto item = dict->GetValue("MyItem"); + if(GetObject(item, n)) + return n + 5; + } + return (int64_t)5; +} +``` +## GetArgumentHeap + +```c++ +/* + Gets a heap object from src + Returns true if argument is of type T + obj is set to src if it returns true +*/ +template +bool GetObjectHeap(TObject& src, T& obj); +``` + +```c++ +//Heres it in code +static void My_Custom(TObject something) +{ + TList* ls; + if(GetObjectHeap(something, ls)) + { + ls->Add((int64_t)42); + } +} +``` \ No newline at end of file diff --git a/content/runtime/types.md b/content/runtime/types.md new file mode 100644 index 0000000..0c98e2b --- /dev/null +++ b/content/runtime/types.md @@ -0,0 +1,21 @@ ++++ +title = 'Types' +date = 2025-10-22T20:43:05-05:00 ++++ + +| Name | IsHeap | Description | TypeOf | +| ===== | ======= | ============ | ====== | +| int64_t | false | A integer | "Long" | +| double | false | A double precision float | "Double" | +| char | false | A character | "Char" | +| bool | false | a boolean | "Boolean" | +| std::string | false | A string | "String" | +| std::regex | false | A regex | "Regex" | +| std::nullptr_t | false | Null | "Null" | +| Undefined | false | Undefined | "Undefined" | +| MethodInvoker | false | MethodInvoker's type | "MethodInvoker" | +| THeapObjectHolder | false | Holds onto heap object | "HeapObject" | +| TVMVersion | false | A CrossLang Version | "Version" | +| TDateTime | false | A date time | "DateTime" | +| std::shared_ptr | false | A Stream | "Stream" | +| std::shared_ptr | false | A Filesystem | "Filesystem" |