work in progress [might break]
This commit is contained in:
parent
785516f975
commit
6bc1e9bbe5
8 changed files with 29 additions and 21 deletions
6
dist/xrfragment.js
vendored
6
dist/xrfragment.js
vendored
|
|
@ -113,8 +113,8 @@ haxe_iterators_ArrayIterator.prototype = {
|
||||||
var xrfragment_Parser = $hx_exports["xrfragment"]["Parser"] = function() { };
|
var xrfragment_Parser = $hx_exports["xrfragment"]["Parser"] = function() { };
|
||||||
xrfragment_Parser.parse = function(key,value,resultMap) {
|
xrfragment_Parser.parse = function(key,value,resultMap) {
|
||||||
var Frag_h = Object.create(null);
|
var Frag_h = Object.create(null);
|
||||||
Frag_h["pos"] = xrfragment_Type.isVector;
|
|
||||||
Frag_h["prio"] = xrfragment_Type.isInt;
|
Frag_h["prio"] = xrfragment_Type.isInt;
|
||||||
|
Frag_h["pos"] = xrfragment_Type.isVector;
|
||||||
if(Object.prototype.hasOwnProperty.call(Frag_h,key)) {
|
if(Object.prototype.hasOwnProperty.call(Frag_h,key)) {
|
||||||
if(Frag_h[key].match(value)) {
|
if(Frag_h[key].match(value)) {
|
||||||
var v = new xrfragment_Value();
|
var v = new xrfragment_Value();
|
||||||
|
|
@ -133,11 +133,11 @@ xrfragment_Parser.parse = function(key,value,resultMap) {
|
||||||
}
|
}
|
||||||
resultMap[key] = v;
|
resultMap[key] = v;
|
||||||
} else {
|
} 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;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} 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 false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
15
doc/RFC.md
15
doc/RFC.md
|
|
@ -1,8 +1,9 @@
|
||||||
> version 1.0.0
|
> 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
|
# URI parser
|
||||||
|
|
||||||
|
|
@ -16,10 +17,10 @@ example URI: `://domain.com/some3d.asset#pos=1,0,0&prio=-5`
|
||||||
|
|
||||||
# XR Fragments (key/value params)
|
# XR Fragments (key/value params)
|
||||||
|
|
||||||
| param | type | category | example |
|
| param | type | category | notes |
|
||||||
|---------|---------------|-------------------------|------------------|
|
|---------|---------------|-------------------------|-------------------------|
|
||||||
| pos | 3D vector | HREF navigation/portals | `#pos=1,0,1` or `#pos=foo` |
|
| 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 |
|
||||||
| prio | int (-10..1) | Asset linking | `#prio=-5` |
|
| pos | 3D vector | HREF navigation/portals | |
|
||||||
|
|
||||||
|
|
||||||
# XR Fragments parser
|
# XR Fragments parser
|
||||||
|
|
@ -38,7 +39,7 @@ the gist of it:
|
||||||
> for anyone to write a parser using either regexes or grammar/lexers
|
> 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.)
|
> therefore expressions/comprehensions are not supported (max wildcard/comparison operators for queries e.g.)
|
||||||
|
|
||||||
# Value types
|
# Parser Value types
|
||||||
|
|
||||||
| type | info | format | example |
|
| type | info | format | example |
|
||||||
|------|------|--------|----------------------------------|
|
|------|------|--------|----------------------------------|
|
||||||
|
|
|
||||||
1
doc/notes/prio.md
Normal file
1
doc/notes/prio.md
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
\#static allow client to ignore lower-prio objects in the renderloop, to compensate frame-drop/cpu/gpu-overload scenario’s
|
||||||
7
make
7
make
|
|
@ -36,9 +36,14 @@ doc(){
|
||||||
cat $1 | awk '/\/\/ / {
|
cat $1 | awk '/\/\/ / {
|
||||||
gsub(".*// ","",$0);
|
gsub(".*// ","",$0);
|
||||||
gsub("# ","\n# ",$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,/^#code /) ){ print "```\n"; system("cat "$2); print "```\n"; next; }
|
||||||
if( match($0,/^#sh /) ){ $1=""; system($0); 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;
|
print $0;
|
||||||
}'
|
}'
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,10 +8,11 @@ class Parser { // #
|
||||||
|
|
||||||
@:keep
|
@:keep
|
||||||
public static function parse(key:String,value:String,resultMap:haxe.DynamicAccess<Dynamic>):Bool {
|
public static function parse(key:String,value:String,resultMap:haxe.DynamicAccess<Dynamic>):Bool {
|
||||||
// | param | type | category | example |
|
var Frag:Map<String, EReg> = new Map<String, EReg>(); // | param | type | category | notes |
|
||||||
var Frag:Map<String, EReg> = new Map<String, EReg>(); // |---------|---------------|-------------------------|------------------|
|
// |---------|---------------|-------------------------|-------------------------|
|
||||||
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 loading / linking | #include doc/notes/prio.md |
|
||||||
Frag.set("prio", Type.isInt); // | prio | int (-10..1) | Asset linking | `#prio=-5` |
|
|
||||||
|
Frag.set("pos", Type.isVector); // | pos | 3D vector | HREF navigation/portals | |
|
||||||
//
|
//
|
||||||
// # XR Fragments parser
|
// # XR Fragments parser
|
||||||
if( Frag.exists(key) ){ //
|
if( Frag.exists(key) ){ //
|
||||||
|
|
@ -51,7 +52,7 @@ class Parser { // #
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
// # Value types
|
// # Parser Value types
|
||||||
//
|
//
|
||||||
// | type | info | format | example |
|
// | type | info | format | example |
|
||||||
class Value { // |------|------|--------|----------------------------------|
|
class Value { // |------|------|--------|----------------------------------|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import xrfragment.Parser;
|
||||||
@:expose // <- makes the class reachable from plain JavaScript
|
@:expose // <- makes the class reachable from plain JavaScript
|
||||||
@:keep // <- avoids accidental removal by dead code elimination
|
@: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 {
|
class URI {
|
||||||
@:keep // # URI parser
|
@:keep // # URI parser
|
||||||
public static function parse(qs:String):haxe.DynamicAccess<Dynamic> { //
|
public static function parse(qs:String):haxe.DynamicAccess<Dynamic> { //
|
||||||
|
|
|
||||||
|
|
@ -283,8 +283,8 @@ var xrfragment_Parser = $hx_exports["xrfragment"]["Parser"] = function() { };
|
||||||
xrfragment_Parser.__name__ = true;
|
xrfragment_Parser.__name__ = true;
|
||||||
xrfragment_Parser.parse = function(key,value,resultMap) {
|
xrfragment_Parser.parse = function(key,value,resultMap) {
|
||||||
var Frag_h = Object.create(null);
|
var Frag_h = Object.create(null);
|
||||||
Frag_h["pos"] = xrfragment_Type.isVector;
|
|
||||||
Frag_h["prio"] = xrfragment_Type.isInt;
|
Frag_h["prio"] = xrfragment_Type.isInt;
|
||||||
|
Frag_h["pos"] = xrfragment_Type.isVector;
|
||||||
if(Object.prototype.hasOwnProperty.call(Frag_h,key)) {
|
if(Object.prototype.hasOwnProperty.call(Frag_h,key)) {
|
||||||
if(Frag_h[key].match(value)) {
|
if(Frag_h[key].match(value)) {
|
||||||
var v = new xrfragment_Value();
|
var v = new xrfragment_Value();
|
||||||
|
|
@ -303,11 +303,11 @@ xrfragment_Parser.parse = function(key,value,resultMap) {
|
||||||
}
|
}
|
||||||
resultMap[key] = v;
|
resultMap[key] = v;
|
||||||
} else {
|
} 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;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} 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 false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -1368,8 +1368,8 @@ class xrfragment_Parser:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def parse(key,value,resultMap):
|
def parse(key,value,resultMap):
|
||||||
Frag = haxe_ds_StringMap()
|
Frag = haxe_ds_StringMap()
|
||||||
Frag.h["pos"] = xrfragment_Type.isVector
|
|
||||||
Frag.h["prio"] = xrfragment_Type.isInt
|
Frag.h["prio"] = xrfragment_Type.isInt
|
||||||
|
Frag.h["pos"] = xrfragment_Type.isVector
|
||||||
if (key in Frag.h):
|
if (key in Frag.h):
|
||||||
_this = Frag.h.get(key,None)
|
_this = Frag.h.get(key,None)
|
||||||
_this.matchObj = python_lib_Re.search(_this.pattern,value)
|
_this.matchObj = python_lib_Re.search(_this.pattern,value)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue