aboutsummaryrefslogtreecommitdiffstats
path: root/src/utils/macro
diff options
context:
space:
mode:
authorRblSb <msrblsb@gmail.com>2025-11-13 13:43:56 +0300
committerRblSb <msrblsb@gmail.com>2025-11-13 23:59:57 +0300
commitc1d1be00c7cace0544c3c6cd152e8c3287b976c4 (patch)
tree416b4534a84ee81032cb2c310167c97c900248f9 /src/utils/macro
parentee3eddc6b80565f6bb458a1fd8f3a83fdd37d554 (diff)
Support yt-dlp with js runtimes
Also adds server version for standalone clients. Remember to update `RblSb/ytdlp-nodejs` if you use this feature.
Diffstat (limited to 'src/utils/macro')
-rw-r--r--src/utils/macro/Macro.hx35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/utils/macro/Macro.hx b/src/utils/macro/Macro.hx
new file mode 100644
index 0000000..118f0e8
--- /dev/null
+++ b/src/utils/macro/Macro.hx
@@ -0,0 +1,35 @@
+package utils.macro;
+
+import haxe.macro.Context;
+import haxe.macro.Expr;
+
+using haxe.macro.Tools;
+
+class Macro {
+ macro public static function getTypedObject(obj:Expr, typePath:Expr):Expr {
+ final type = Context.getType(typePath.toString());
+ switch (type.follow()) {
+ case TAnonymous(_.get() => td):
+ final name = obj.toString();
+ if (obj.expr.match(EObjectDecl(_))) {
+ throw new Error('$name should be passed as reference (inside of variable)', obj.pos);
+ }
+ final e:Expr = {
+ expr: EObjectDecl([
+ for (field in td.fields) {
+ field: field.name,
+ expr: macro $p{['$name', '${field.name}']},
+ }
+ ]),
+ pos: Context.currentPos()
+ }
+ return e;
+ default:
+ throw new Error(type.toString() + " should be typedef structure", typePath.pos);
+ }
+ }
+
+ macro public static function getBuildTime():Expr {
+ return macro $v{Date.now().toString()};
+ }
+}
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage