diff --git a/dist/xrfragment.js b/dist/xrfragment.js index ceabf27..4506c3d 100644 --- a/dist/xrfragment.js +++ b/dist/xrfragment.js @@ -113,8 +113,8 @@ haxe_iterators_ArrayIterator.prototype = { var xrfragment_Parser = $hx_exports["xrfragment"]["Parser"] = function() { }; xrfragment_Parser.parse = function(key,value,resultMap) { var Frag_h = Object.create(null); - Frag_h["pos"] = xrfragment_Type.isVector; Frag_h["prio"] = xrfragment_Type.isInt; + Frag_h["pos"] = xrfragment_Type.isVector; if(Object.prototype.hasOwnProperty.call(Frag_h,key)) { if(Frag_h[key].match(value)) { var v = new xrfragment_Value(); @@ -133,11 +133,11 @@ xrfragment_Parser.parse = function(key,value,resultMap) { } resultMap[key] = v; } else { - console.log("src/xrfragment/Parser.hx:32:","[ i ] fragment '" + key + "' has incompatible value (" + value + ")"); + console.log("src/xrfragment/Parser.hx:33:","[ i ] fragment '" + key + "' has incompatible value (" + value + ")"); return false; } } else { - console.log("src/xrfragment/Parser.hx:33:","[ i ] fragment '" + key + "' does not exist or has no type defined (yet)"); + console.log("src/xrfragment/Parser.hx:34:","[ i ] fragment '" + key + "' does not exist or has no type defined (yet)"); return false; } return true; diff --git a/doc/RFC.md b/doc/RFC.md index 6771332..aa5ce32 100644 --- a/doc/RFC.md +++ b/doc/RFC.md @@ -1,8 +1,9 @@ > version 1.0.0 -date: 2023-03-31T14:48:17+0200 (generated by `./make doc`) +date: 2023-03-31T15:57:18+0200 (generated by `./make doc`) -example URI: `://domain.com/some3d.asset#pos=1,0,0&prio=-5` +## +# example URI: `://domain.com/some3d.asset#pos=1,0,0&prio=-5` # URI parser @@ -16,10 +17,10 @@ example URI: `://domain.com/some3d.asset#pos=1,0,0&prio=-5` # XR Fragments (key/value params) -| param | type | category | example | -|---------|---------------|-------------------------|------------------| -| pos | 3D vector | HREF navigation/portals | `#pos=1,0,1` or `#pos=foo` | -| prio | int (-10..1) | Asset linking | `#prio=-5` | +| param | type | category | notes | +|---------|---------------|-------------------------|-------------------------| +| prio | int (-10..1) | Asset loading / linking | \#static allow client to ignore lower-prio objects in the renderloop, to compensate frame-drop/cpu/gpu-overload scenario’soc/notes/prio.md | +| pos | 3D vector | HREF navigation/portals | | # XR Fragments parser @@ -38,7 +39,7 @@ the gist of it: > for anyone to write a parser using either regexes or grammar/lexers > therefore expressions/comprehensions are not supported (max wildcard/comparison operators for queries e.g.) -# Value types +# Parser Value types | type | info | format | example | |------|------|--------|----------------------------------| diff --git a/doc/notes/prio.md b/doc/notes/prio.md new file mode 100644 index 0000000..24ea0bb --- /dev/null +++ b/doc/notes/prio.md @@ -0,0 +1 @@ +\#static allow client to ignore lower-prio objects in the renderloop, to compensate frame-drop/cpu/gpu-overload scenario’s diff --git a/make b/make index d91975d..ea7ce9b 100755 --- a/make +++ b/make @@ -36,9 +36,14 @@ doc(){ cat $1 | awk '/\/\/ / { gsub(".*// ","",$0); gsub("# ","\n# ",$0); - if( match($0,/^#include /) ){ system("cat "$2); next; } if( match($0,/^#code /) ){ print "```\n"; system("cat "$2); print "```\n"; next; } if( match($0,/^#sh /) ){ $1=""; system($0); next; } + if( match($0,/#include /) ) { + o=$0; gsub(/.*#include/,"#include",$0); f=$2; $0=o; + cmd="cat "f + cmd | getline text; close(cmd) + gsub(/#include \w/, text) + } print $0; }' } diff --git a/src/xrfragment/Parser.hx b/src/xrfragment/Parser.hx index 58451a7..f8f42aa 100644 --- a/src/xrfragment/Parser.hx +++ b/src/xrfragment/Parser.hx @@ -8,10 +8,11 @@ class Parser { // # @:keep public static function parse(key:String,value:String,resultMap:haxe.DynamicAccess):Bool { - // | param | type | category | example | - var Frag:Map = new Map(); // |---------|---------------|-------------------------|------------------| - Frag.set("pos", Type.isVector); // | pos | 3D vector | HREF navigation/portals | `#pos=1,0,1` or `#pos=foo` | - Frag.set("prio", Type.isInt); // | prio | int (-10..1) | Asset linking | `#prio=-5` | + var Frag:Map = new Map(); // | param | type | category | notes | + // |---------|---------------|-------------------------|-------------------------| + Frag.set("prio", Type.isInt); // | prio | int (-10..1) | Asset loading / linking | #include doc/notes/prio.md | + + Frag.set("pos", Type.isVector); // | pos | 3D vector | HREF navigation/portals | | // // # XR Fragments parser if( Frag.exists(key) ){ // @@ -51,7 +52,7 @@ class Parser { // # } } - // # Value types + // # Parser Value types // // | type | info | format | example | class Value { // |------|------|--------|----------------------------------| diff --git a/src/xrfragment/URI.hx b/src/xrfragment/URI.hx index 1a2e883..6378e03 100644 --- a/src/xrfragment/URI.hx +++ b/src/xrfragment/URI.hx @@ -5,7 +5,7 @@ import xrfragment.Parser; @:expose // <- makes the class reachable from plain JavaScript @:keep // <- avoids accidental removal by dead code elimination // - // example URI: `://domain.com/some3d.asset#pos=1,0,0&prio=-5` + // ### example URI: `://domain.com/some3d.asset#pos=1,0,0&prio=-5` class URI { @:keep // # URI parser public static function parse(qs:String):haxe.DynamicAccess { // diff --git a/test/generated/test.js b/test/generated/test.js index 0c73d26..d6fbb7b 100644 --- a/test/generated/test.js +++ b/test/generated/test.js @@ -283,8 +283,8 @@ var xrfragment_Parser = $hx_exports["xrfragment"]["Parser"] = function() { }; xrfragment_Parser.__name__ = true; xrfragment_Parser.parse = function(key,value,resultMap) { var Frag_h = Object.create(null); - Frag_h["pos"] = xrfragment_Type.isVector; Frag_h["prio"] = xrfragment_Type.isInt; + Frag_h["pos"] = xrfragment_Type.isVector; if(Object.prototype.hasOwnProperty.call(Frag_h,key)) { if(Frag_h[key].match(value)) { var v = new xrfragment_Value(); @@ -303,11 +303,11 @@ xrfragment_Parser.parse = function(key,value,resultMap) { } resultMap[key] = v; } else { - console.log("src/xrfragment/Parser.hx:32:","[ i ] fragment '" + key + "' has incompatible value (" + value + ")"); + console.log("src/xrfragment/Parser.hx:33:","[ i ] fragment '" + key + "' has incompatible value (" + value + ")"); return false; } } else { - console.log("src/xrfragment/Parser.hx:33:","[ i ] fragment '" + key + "' does not exist or has no type defined (yet)"); + console.log("src/xrfragment/Parser.hx:34:","[ i ] fragment '" + key + "' does not exist or has no type defined (yet)"); return false; } return true; diff --git a/test/generated/test.py b/test/generated/test.py index 1a06412..43c88d1 100644 --- a/test/generated/test.py +++ b/test/generated/test.py @@ -1368,8 +1368,8 @@ class xrfragment_Parser: @staticmethod def parse(key,value,resultMap): Frag = haxe_ds_StringMap() - Frag.h["pos"] = xrfragment_Type.isVector Frag.h["prio"] = xrfragment_Type.isInt + Frag.h["pos"] = xrfragment_Type.isVector if (key in Frag.h): _this = Frag.h.get(key,None) _this.matchObj = python_lib_Re.search(_this.pattern,value)