From 5588171b3668ba852012115c08ac4f8cdcd89070 Mon Sep 17 00:00:00 2001 From: Leon van Kammen Date: Fri, 28 Apr 2023 14:27:30 +0200 Subject: [PATCH] work in progress [might break] --- dist/xrfragment.js | 15 +++++++++++- dist/xrfragment.lua | 21 ++++++++++++++++ dist/xrfragment.module.js | 15 +++++++++++- dist/xrfragment.py | 19 +++++++++++++-- doc/RFC.md | 50 +-------------------------------------- doc/fragments.awk | 5 ++-- src/xrfragment/XRF.hx | 2 ++ test/generated/test.js | 24 ++++++++++++++----- test/generated/test.py | 22 +++++++++++++---- test/test.js | 3 +++ 10 files changed, 111 insertions(+), 65 deletions(-) diff --git a/dist/xrfragment.js b/dist/xrfragment.js index fd0844d..76c6b9e 100644 --- a/dist/xrfragment.js +++ b/dist/xrfragment.js @@ -476,11 +476,17 @@ xrfragment_URI.parse = function(qs,browser_override) { } return resultMap; }; -var xrfragment_XRF = function(_fragment,_flags) { +var xrfragment_XRF = $hx_exports["xrfragment"]["XRF"] = function(_fragment,_flags) { this.fragment = _fragment; this.flags = _flags; }; xrfragment_XRF.__name__ = true; +xrfragment_XRF.set = function(flag,flags) { + return flags | flag; +}; +xrfragment_XRF.unset = function(flag,flags) { + return flags & ~flag; +}; xrfragment_XRF.prototype = { is: function(flag) { return (this.flags & flag) != 0; @@ -563,15 +569,22 @@ xrfragment_XRF.ROUNDROBIN = 16; xrfragment_XRF.BROWSER_OVERRIDE = 32; xrfragment_XRF.PV_OVERRIDE = 64; xrfragment_XRF.PV_EXECUTE = 128; +xrfragment_XRF.T_COLOR = 256; xrfragment_XRF.T_INT = 512; +xrfragment_XRF.T_FLOAT = 1024; xrfragment_XRF.T_VECTOR2 = 2048; xrfragment_XRF.T_VECTOR3 = 4096; xrfragment_XRF.T_URL = 8192; xrfragment_XRF.T_PREDEFINED_VIEW = 16384; xrfragment_XRF.T_STRING = 32768; xrfragment_XRF.T_STRING_OBJ = 65536; +xrfragment_XRF.T_STRING_OBJ_PROP = 131072; xrfragment_XRF.isColor = new EReg("^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$",""); xrfragment_XRF.isInt = new EReg("^[0-9]+$",""); xrfragment_XRF.isFloat = new EReg("^[0-9]+\\.[0-9]+$",""); +xrfragment_XRF.isVector = new EReg("([,]+|\\w)",""); +xrfragment_XRF.isUrl = new EReg("(://)?\\..*",""); +xrfragment_XRF.isUrlOrPretypedView = new EReg("(^#|://)?\\..*",""); +xrfragment_XRF.isString = new EReg(".*",""); })({}); var xrfragment = $hx_exports["xrfragment"]; diff --git a/dist/xrfragment.lua b/dist/xrfragment.lua index 7ce7cc9..af97d13 100644 --- a/dist/xrfragment.lua +++ b/dist/xrfragment.lua @@ -2137,7 +2137,14 @@ __xrfragment_XRF.super = function(self,_fragment,_flags) self.fragment = _fragment; self.flags = _flags; end +_hx_exports["xrfragment"]["XRF"] = __xrfragment_XRF __xrfragment_XRF.__name__ = true +__xrfragment_XRF.set = function(flag,flags) + do return _hx_bit.bor(flags,flag) end; +end +__xrfragment_XRF.unset = function(flag,flags) + do return _hx_bit.band(flags,_hx_bit.bnot(flag)) end; +end __xrfragment_XRF.prototype = _hx_e(); __xrfragment_XRF.prototype.is = function(self,flag) do return (_hx_bit.band(self.flags,flag)) ~= 0 end @@ -2362,8 +2369,12 @@ local _hx_static_init = function() __xrfragment_XRF.PV_EXECUTE = 128; + __xrfragment_XRF.T_COLOR = 256; + __xrfragment_XRF.T_INT = 512; + __xrfragment_XRF.T_FLOAT = 1024; + __xrfragment_XRF.T_VECTOR2 = 2048; __xrfragment_XRF.T_VECTOR3 = 4096; @@ -2376,12 +2387,22 @@ local _hx_static_init = function() __xrfragment_XRF.T_STRING_OBJ = 65536; + __xrfragment_XRF.T_STRING_OBJ_PROP = 131072; + __xrfragment_XRF.isColor = EReg.new("^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$", ""); __xrfragment_XRF.isInt = EReg.new("^[0-9]+$", ""); __xrfragment_XRF.isFloat = EReg.new("^[0-9]+\\.[0-9]+$", ""); + __xrfragment_XRF.isVector = EReg.new("([,]+|\\w)", ""); + + __xrfragment_XRF.isUrl = EReg.new("(://)?\\..*", ""); + + __xrfragment_XRF.isUrlOrPretypedView = EReg.new("(^#|://)?\\..*", ""); + + __xrfragment_XRF.isString = EReg.new(".*", ""); + end diff --git a/dist/xrfragment.module.js b/dist/xrfragment.module.js index 32e27aa..08aa98d 100644 --- a/dist/xrfragment.module.js +++ b/dist/xrfragment.module.js @@ -476,11 +476,17 @@ xrfragment_URI.parse = function(qs,browser_override) { } return resultMap; }; -var xrfragment_XRF = function(_fragment,_flags) { +var xrfragment_XRF = $hx_exports["xrfragment"]["XRF"] = function(_fragment,_flags) { this.fragment = _fragment; this.flags = _flags; }; xrfragment_XRF.__name__ = true; +xrfragment_XRF.set = function(flag,flags) { + return flags | flag; +}; +xrfragment_XRF.unset = function(flag,flags) { + return flags & ~flag; +}; xrfragment_XRF.prototype = { is: function(flag) { return (this.flags & flag) != 0; @@ -563,16 +569,23 @@ xrfragment_XRF.ROUNDROBIN = 16; xrfragment_XRF.BROWSER_OVERRIDE = 32; xrfragment_XRF.PV_OVERRIDE = 64; xrfragment_XRF.PV_EXECUTE = 128; +xrfragment_XRF.T_COLOR = 256; xrfragment_XRF.T_INT = 512; +xrfragment_XRF.T_FLOAT = 1024; xrfragment_XRF.T_VECTOR2 = 2048; xrfragment_XRF.T_VECTOR3 = 4096; xrfragment_XRF.T_URL = 8192; xrfragment_XRF.T_PREDEFINED_VIEW = 16384; xrfragment_XRF.T_STRING = 32768; xrfragment_XRF.T_STRING_OBJ = 65536; +xrfragment_XRF.T_STRING_OBJ_PROP = 131072; xrfragment_XRF.isColor = new EReg("^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$",""); xrfragment_XRF.isInt = new EReg("^[0-9]+$",""); xrfragment_XRF.isFloat = new EReg("^[0-9]+\\.[0-9]+$",""); +xrfragment_XRF.isVector = new EReg("([,]+|\\w)",""); +xrfragment_XRF.isUrl = new EReg("(://)?\\..*",""); +xrfragment_XRF.isUrlOrPretypedView = new EReg("(^#|://)?\\..*",""); +xrfragment_XRF.isString = new EReg(".*",""); })({}); var xrfragment = $hx_exports["xrfragment"]; export default xrfragment; diff --git a/dist/xrfragment.py b/dist/xrfragment.py index 5567101..76eff90 100644 --- a/dist/xrfragment.py +++ b/dist/xrfragment.py @@ -1563,7 +1563,7 @@ class xrfragment_XRF: __slots__ = ("fragment", "flags", "x", "y", "z", "color", "string", "int", "float", "args", "query") _hx_fields = ["fragment", "flags", "x", "y", "z", "color", "string", "int", "float", "args", "query"] _hx_methods = ["is", "validate", "guessType"] - _hx_statics = ["ASSET", "PROP_BIND", "QUERY_OPERATOR", "PROMPT", "ROUNDROBIN", "BROWSER_OVERRIDE", "PV_OVERRIDE", "PV_EXECUTE", "T_INT", "T_VECTOR2", "T_VECTOR3", "T_URL", "T_PREDEFINED_VIEW", "T_STRING", "T_STRING_OBJ", "isColor", "isInt", "isFloat"] + _hx_statics = ["ASSET", "PROP_BIND", "QUERY_OPERATOR", "PROMPT", "ROUNDROBIN", "BROWSER_OVERRIDE", "PV_OVERRIDE", "PV_EXECUTE", "T_COLOR", "T_INT", "T_FLOAT", "T_VECTOR2", "T_VECTOR3", "T_URL", "T_PREDEFINED_VIEW", "T_STRING", "T_STRING_OBJ", "T_STRING_OBJ_PROP", "isColor", "isInt", "isFloat", "isVector", "isUrl", "isUrlOrPretypedView", "isString", "set", "unset"] def __init__(self,_fragment,_flags): self.query = None @@ -1630,6 +1630,14 @@ class xrfragment_XRF: if (_this.matchObj is not None): v.int = Std.parseInt(_hx_str) + @staticmethod + def set(flag,flags): + return (flags | flag) + + @staticmethod + def unset(flag,flags): + return (flags & ~flag) + Math.NEGATIVE_INFINITY = float("-inf") Math.POSITIVE_INFINITY = float("inf") @@ -1647,13 +1655,20 @@ xrfragment_XRF.ROUNDROBIN = 16 xrfragment_XRF.BROWSER_OVERRIDE = 32 xrfragment_XRF.PV_OVERRIDE = 64 xrfragment_XRF.PV_EXECUTE = 128 +xrfragment_XRF.T_COLOR = 256 xrfragment_XRF.T_INT = 512 +xrfragment_XRF.T_FLOAT = 1024 xrfragment_XRF.T_VECTOR2 = 2048 xrfragment_XRF.T_VECTOR3 = 4096 xrfragment_XRF.T_URL = 8192 xrfragment_XRF.T_PREDEFINED_VIEW = 16384 xrfragment_XRF.T_STRING = 32768 xrfragment_XRF.T_STRING_OBJ = 65536 +xrfragment_XRF.T_STRING_OBJ_PROP = 131072 xrfragment_XRF.isColor = EReg("^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$","") xrfragment_XRF.isInt = EReg("^[0-9]+$","") -xrfragment_XRF.isFloat = EReg("^[0-9]+\\.[0-9]+$","") \ No newline at end of file +xrfragment_XRF.isFloat = EReg("^[0-9]+\\.[0-9]+$","") +xrfragment_XRF.isVector = EReg("([,]+|\\w)","") +xrfragment_XRF.isUrl = EReg("(://)?\\..*","") +xrfragment_XRF.isUrlOrPretypedView = EReg("(^#|://)?\\..*","") +xrfragment_XRF.isString = EReg(".*","") \ No newline at end of file diff --git a/doc/RFC.md b/doc/RFC.md index 4be7960..d1500d5 100644 --- a/doc/RFC.md +++ b/doc/RFC.md @@ -4,7 +4,7 @@ > version 1.0.0 -date: 2023-04-07T13:41:47+0200
+date: 2023-04-27T22:44:39+0200
[![Actions Status](https://github.com/coderofsalvation/xrfragment/workflows/test/badge.svg)](https://github.com/coderofsalvation/xrfragment/actions) # XRFragment Grammar @@ -40,58 +40,10 @@ date: 2023-04-07T13:41:47+0200
1. fragment-values are urlencoded (space becomes `+` using `encodeUriComponent` e.g.) 1. every recognized fragment key/value-pair is added to a central map/associative array/object -# XR Fragments (key/value params) - -> ⛁ = define in 3D asset-file (as custom property or default projection)
-> ☇ = mutable, using navigator URI (`document.location.href` e.g.)
- -| param | type | scope(s) | 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’s | -| pos | 3D vector | ⛁ ☇ |HREF navigation/portals | | -| q | string | ⛁ |Query Selector | | - - # XR Fragments parser > icanhazcode? yes, see [Parser.hx](https://github.com/coderofsalvation/xrfragment/blob/main/src/xrfragment/Parser.hx) the gist of it: 1. check if param exist -1. each key has a regex to validate its value-type (see regexes) -1. extract the type -1. use `|` on stringvalues, to split multiple values -1. for each multiple value, guess the type -1. `,` assumes 1D/2D/3D vector-values like x[,y[,z]] -1. parseFloat(..) and parseInt(..) is applied to vector/float and int values -1. anything else will be treated as string-value -1. incompatible value-types will be dropped / not used - - -> the xrfragment specification should stay simple enough - -> 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.) - -# Parser Value types - -| type | info | format | example | -|------|------|--------|----------------------------------| -|vector| x,y,z| comma-separated | #pos=1,2,3 | -|string| color| FFFFFF (hex) | #fog=5m,FFAACC | -|string| | | #q=-sun | -|int | | [-]x[xxxxx] | #price:>=100 | -|float | | [-]x[.xxxx] (ieee)| #prio=-20 | -|array | mixed| \|-separated | #pos=0,0,0\|90,0,0 | - - -> rule for thumb: type-limitations will piggyback JSON limitations (IEEE floatsize e.g.) -Regexes: - -1. hex colors are detected using regex `/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/` -1. integers are detected using regex `/^[0-9]+$/` -1. floats are detected using regex `/^[0-9]+\.[0-9]+$/` -1. vectors are detected using regex `/[,]/` (but can also be an string referring to an entity-ID in the asset) -1. anything else is string `/.*/` diff --git a/doc/fragments.awk b/doc/fragments.awk index 478a814..810bb09 100644 --- a/doc/fragments.awk +++ b/doc/fragments.awk @@ -4,11 +4,12 @@ BEGIN{ PV_OVERRIDE="🔓" BROWSER_OVERRIDE="👩" PROMPT="✋?" + BROWSER_OVERRIDE_TOPLEVEL="🌐" print ROUNDROBIN" = multiple values will be roundrobin'ed
" - print ASSET" = immutable value(s) are defined in 3D asset
" + print ASSET" = value(s) can only defined in 3D asset (immutable)
" print PV_OVERRIDE" = value(s) can be overwritten by [predefined_view](#predefined_view)
" print BROWSER_OVERRIDE" = value(s) can be overwritten by [URL browser_override](#browser_override)
" - print PROMPT" = value(s) can be overwritten only after confirmation of user

" + print PROMPT" = value(s) can be overwritten only offering confirmation/undo to user

" print "| fragment | type | write access | scope |" print "|----------|------|--------------|-------|" } diff --git a/src/xrfragment/XRF.hx b/src/xrfragment/XRF.hx index fd7013d..8c843a4 100644 --- a/src/xrfragment/XRF.hx +++ b/src/xrfragment/XRF.hx @@ -1,5 +1,7 @@ package xrfragment; +@:expose // <- makes the class reachable from plain JavaScript +@:keep // <- avoids accidental removal by dead code elimination class XRF { /* diff --git a/test/generated/test.js b/test/generated/test.js index ba8c0c7..7d58da0 100644 --- a/test/generated/test.js +++ b/test/generated/test.js @@ -341,15 +341,14 @@ xrfragment_Parser.parse = function(key,value,resultMap) { Frag_h["t"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.ROUNDROBIN | xrfragment_XRF.T_VECTOR2 | xrfragment_XRF.BROWSER_OVERRIDE; Frag_h["gravity"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3; Frag_h["physics"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR3; - Frag_h["scroll"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_STRING; Frag_h["fov"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_INT | xrfragment_XRF.BROWSER_OVERRIDE; Frag_h["clip"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_VECTOR2 | xrfragment_XRF.BROWSER_OVERRIDE; Frag_h["fog"] = xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.T_STRING | xrfragment_XRF.BROWSER_OVERRIDE; Frag_h["namespace"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING; - Frag_h["SPFX"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING; + Frag_h["SPDX"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING; Frag_h["unit"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING; Frag_h["description"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING; - Frag_h["src_session"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.BROWSER_OVERRIDE | xrfragment_XRF.PROMPT; + Frag_h["session"] = xrfragment_XRF.ASSET | xrfragment_XRF.T_URL | xrfragment_XRF.PV_OVERRIDE | xrfragment_XRF.BROWSER_OVERRIDE | xrfragment_XRF.PROMPT; if(value.length == 0 && !Object.prototype.hasOwnProperty.call(Frag_h,key)) { resultMap[key] = new xrfragment_XRF(key,xrfragment_XRF.PV_EXECUTE | xrfragment_XRF.BROWSER_OVERRIDE); return true; @@ -361,12 +360,12 @@ xrfragment_Parser.parse = function(key,value,resultMap) { if(Object.prototype.hasOwnProperty.call(Frag_h,key)) { var v = new xrfragment_XRF(key,Frag_h[key]); if(!v.validate(value)) { - console.log("src/xrfragment/Parser.hx:75:","[ i ] fragment '" + key + "' has incompatible value (" + value + ")"); + console.log("src/xrfragment/Parser.hx:74:","[ i ] fragment '" + key + "' has incompatible value (" + value + ")"); return false; } resultMap[key] = v; } else { - console.log("src/xrfragment/Parser.hx:79:","[ i ] fragment '" + key + "' does not exist or has no type typed (yet)"); + console.log("src/xrfragment/Parser.hx:78:","[ i ] fragment '" + key + "' does not exist or has no type typed (yet)"); return false; } return true; @@ -587,11 +586,17 @@ xrfragment_URI.parse = function(qs,browser_override) { } return resultMap; }; -var xrfragment_XRF = function(_fragment,_flags) { +var xrfragment_XRF = $hx_exports["xrfragment"]["XRF"] = function(_fragment,_flags) { this.fragment = _fragment; this.flags = _flags; }; xrfragment_XRF.__name__ = true; +xrfragment_XRF.set = function(flag,flags) { + return flags | flag; +}; +xrfragment_XRF.unset = function(flag,flags) { + return flags & ~flag; +}; xrfragment_XRF.prototype = { is: function(flag) { return (this.flags & flag) != 0; @@ -675,16 +680,23 @@ xrfragment_XRF.ROUNDROBIN = 16; xrfragment_XRF.BROWSER_OVERRIDE = 32; xrfragment_XRF.PV_OVERRIDE = 64; xrfragment_XRF.PV_EXECUTE = 128; +xrfragment_XRF.T_COLOR = 256; xrfragment_XRF.T_INT = 512; +xrfragment_XRF.T_FLOAT = 1024; xrfragment_XRF.T_VECTOR2 = 2048; xrfragment_XRF.T_VECTOR3 = 4096; xrfragment_XRF.T_URL = 8192; xrfragment_XRF.T_PREDEFINED_VIEW = 16384; xrfragment_XRF.T_STRING = 32768; xrfragment_XRF.T_STRING_OBJ = 65536; +xrfragment_XRF.T_STRING_OBJ_PROP = 131072; xrfragment_XRF.isColor = new EReg("^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$",""); xrfragment_XRF.isInt = new EReg("^[0-9]+$",""); xrfragment_XRF.isFloat = new EReg("^[0-9]+\\.[0-9]+$",""); +xrfragment_XRF.isVector = new EReg("([,]+|\\w)",""); +xrfragment_XRF.isUrl = new EReg("(://)?\\..*",""); +xrfragment_XRF.isUrlOrPretypedView = new EReg("(^#|://)?\\..*",""); +xrfragment_XRF.isString = new EReg(".*",""); Test.main(); })({}); var xrfragment = $hx_exports["xrfragment"]; diff --git a/test/generated/test.py b/test/generated/test.py index 142a865..096adcb 100644 --- a/test/generated/test.py +++ b/test/generated/test.py @@ -1422,15 +1422,14 @@ class xrfragment_Parser: Frag.h["t"] = ((((xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE) | xrfragment_XRF.ROUNDROBIN) | xrfragment_XRF.T_VECTOR2) | xrfragment_XRF.BROWSER_OVERRIDE) Frag.h["gravity"] = ((xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE) | xrfragment_XRF.T_VECTOR3) Frag.h["physics"] = ((xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE) | xrfragment_XRF.T_VECTOR3) - Frag.h["scroll"] = ((xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE) | xrfragment_XRF.T_STRING) Frag.h["fov"] = (((xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE) | xrfragment_XRF.T_INT) | xrfragment_XRF.BROWSER_OVERRIDE) Frag.h["clip"] = (((xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE) | xrfragment_XRF.T_VECTOR2) | xrfragment_XRF.BROWSER_OVERRIDE) Frag.h["fog"] = (((xrfragment_XRF.ASSET | xrfragment_XRF.PV_OVERRIDE) | xrfragment_XRF.T_STRING) | xrfragment_XRF.BROWSER_OVERRIDE) Frag.h["namespace"] = (xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING) - Frag.h["SPFX"] = (xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING) + Frag.h["SPDX"] = (xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING) Frag.h["unit"] = (xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING) Frag.h["description"] = (xrfragment_XRF.ASSET | xrfragment_XRF.T_STRING) - Frag.h["src_session"] = ((((xrfragment_XRF.ASSET | xrfragment_XRF.T_URL) | xrfragment_XRF.PV_OVERRIDE) | xrfragment_XRF.BROWSER_OVERRIDE) | xrfragment_XRF.PROMPT) + Frag.h["session"] = ((((xrfragment_XRF.ASSET | xrfragment_XRF.T_URL) | xrfragment_XRF.PV_OVERRIDE) | xrfragment_XRF.BROWSER_OVERRIDE) | xrfragment_XRF.PROMPT) if ((len(value) == 0) and (not (key in Frag.h))): value1 = xrfragment_XRF(key,(xrfragment_XRF.PV_EXECUTE | xrfragment_XRF.BROWSER_OVERRIDE)) setattr(resultMap,(("_hx_" + key) if ((key in python_Boot.keywords)) else (("_hx_" + key) if (((((len(key) > 2) and ((ord(key[0]) == 95))) and ((ord(key[1]) == 95))) and ((ord(key[(len(key) - 1)]) != 95)))) else key)),value1) @@ -1678,7 +1677,7 @@ class xrfragment_XRF: __slots__ = ("fragment", "flags", "x", "y", "z", "color", "string", "int", "float", "args", "query") _hx_fields = ["fragment", "flags", "x", "y", "z", "color", "string", "int", "float", "args", "query"] _hx_methods = ["is", "validate", "guessType"] - _hx_statics = ["ASSET", "PROP_BIND", "QUERY_OPERATOR", "PROMPT", "ROUNDROBIN", "BROWSER_OVERRIDE", "PV_OVERRIDE", "PV_EXECUTE", "T_INT", "T_VECTOR2", "T_VECTOR3", "T_URL", "T_PREDEFINED_VIEW", "T_STRING", "T_STRING_OBJ", "isColor", "isInt", "isFloat"] + _hx_statics = ["ASSET", "PROP_BIND", "QUERY_OPERATOR", "PROMPT", "ROUNDROBIN", "BROWSER_OVERRIDE", "PV_OVERRIDE", "PV_EXECUTE", "T_COLOR", "T_INT", "T_FLOAT", "T_VECTOR2", "T_VECTOR3", "T_URL", "T_PREDEFINED_VIEW", "T_STRING", "T_STRING_OBJ", "T_STRING_OBJ_PROP", "isColor", "isInt", "isFloat", "isVector", "isUrl", "isUrlOrPretypedView", "isString", "set", "unset"] def __init__(self,_fragment,_flags): self.query = None @@ -1745,6 +1744,14 @@ class xrfragment_XRF: if (_this.matchObj is not None): v.int = Std.parseInt(_hx_str) + @staticmethod + def set(flag,flags): + return (flags | flag) + + @staticmethod + def unset(flag,flags): + return (flags & ~flag) + Math.NEGATIVE_INFINITY = float("-inf") Math.POSITIVE_INFINITY = float("inf") @@ -1763,15 +1770,22 @@ xrfragment_XRF.ROUNDROBIN = 16 xrfragment_XRF.BROWSER_OVERRIDE = 32 xrfragment_XRF.PV_OVERRIDE = 64 xrfragment_XRF.PV_EXECUTE = 128 +xrfragment_XRF.T_COLOR = 256 xrfragment_XRF.T_INT = 512 +xrfragment_XRF.T_FLOAT = 1024 xrfragment_XRF.T_VECTOR2 = 2048 xrfragment_XRF.T_VECTOR3 = 4096 xrfragment_XRF.T_URL = 8192 xrfragment_XRF.T_PREDEFINED_VIEW = 16384 xrfragment_XRF.T_STRING = 32768 xrfragment_XRF.T_STRING_OBJ = 65536 +xrfragment_XRF.T_STRING_OBJ_PROP = 131072 xrfragment_XRF.isColor = EReg("^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$","") xrfragment_XRF.isInt = EReg("^[0-9]+$","") xrfragment_XRF.isFloat = EReg("^[0-9]+\\.[0-9]+$","") +xrfragment_XRF.isVector = EReg("([,]+|\\w)","") +xrfragment_XRF.isUrl = EReg("(://)?\\..*","") +xrfragment_XRF.isUrlOrPretypedView = EReg("(^#|://)?\\..*","") +xrfragment_XRF.isString = EReg(".*","") Test.main() diff --git a/test/test.js b/test/test.js index e80c92f..233e877 100644 --- a/test/test.js +++ b/test/test.js @@ -16,3 +16,6 @@ print( XF.URI.parse('://foo.com/1.gltf#pos=1.0,2.0,3.0&q=-.foo&t=1,100',true) ); let q = new XF.Query(); print( q.parse("-.foo -plane") ) print( q.parse("price:>2") ) + +frags = XF.URI.parse('#my_view&t=1,2') +console.dir(XF)