XeltoSS Documentation

Ivo Yankulovski edited this page Oct 20, 2018 · 7 revisions

Author: Zeta Ret, Ivo Yankulovski
Zeta Ret XeltoSS

ProtoSS Transformator to JS Class

Requires: protoss.all.js v1.04b
Version: 1.04b
Date: 2017 - Today

required*

XeltoSS

Properties

scriptContainer HTMLElement
default null, container to append new script tags

scriptContainerAppendMethod String
default "appendChild", method name to call at scriptContainer

protossPrefix String
default "protoss__" prefix in package

xeltossPrefix String
default "xeltoss__", prefix in package

xeltossMethodSuffix String
default "X", x scoped method suffix after transpile (add "_x" in function definition to preserve scope, lookup Function.prototype.xcoped)

statisAsStatic Boolean
default false, methods added using "statis" will be converted to static of the class

embedMaps Object
default {}, used in "addEmbedMap" and "toCls", matches object supername and key in order to build custom body properties defined externally

augmentKeyMap Object
default {}, used in "augmentKey" and "argumentKeyMatch", identify alternative keys based on augmenting object supername

noKeyIdentificationChain Object
default {}, used in "argumentKeyMatch" and "identifyKeyChain" to identify missing key values, misconfiguration might result "void"

toppack Object
default null, top package you should set "window" in most cases, used everywhere inside code to obtain classes by supername

scopeMap Object
default {}, scope cache map used in external or proxy builders (usually will refer to it through XeltoSS this object as shared memory mechanism)

preserveScope Boolean
default false, protected methods using "_p" will generate scoped method and replace original (lookup Function.prototype.xcoped)

fractalizedScope Boolean
default false, used in external and proxy AST/instruction builders to successfully identify stacks of scope (usually achieved by defining functions inside each other and refering to scope outside its own), this concept is not implemented in the majority of source code parsers but in Virtual Machines

obscureTimers Boolean
default false, remove setInterval and setTimeout during hybridization process

setInterval Function
default null, reference to original setInterval function

setTimeout Function
default null, reference to original setTimeout function

tokens Object
default null, map of string tokens

keywords Object
default null, map of string keywords

operators Object
default null, map of string operators

autoget Boolean
default true, allow automatic convertion of marked methods as getters

autoGetPrefix String
default "get_", method name prefix mark

autoset Boolean
default true, allow automatic convertion of marked methods as setters

autoSetPrefix String
default "set_", method name prefix mark

methodJoin String
default "", used string in joining method array

bodyJoin String
default "", used string in joining body logic array

overextendHandler Function
default null, define custom extraction of body properties

classHandler Function
default null, define custom construction of class output string

tossIgnore Boolean
default false, disable ProtoSS transfer of prototypes, method maps and method transfer

deflatInterfaces Boolean
default true, used in assembly process if deflat allowed

deflatAbstracts Boolean
default true, used in assembly process if deflat allowed

deflatConstructs Boolean
default true, used in assembly process if deflat allowed

deflatInheritance Boolean
default true, used in assembly process if deflat allowed

deflatStruct Object
default {}, used through "deflatCls"

objectStringify Function
default null, custom stringification of objects, lookup JSON.stringify

arrayStringify Function
default null, custom stringification of arrays, lookup JSON.stringify

methodTransfer Boolean
default false, inherited methods will not be added to class definition, can be transfered from super prototype

autoConstructor Boolean
default true, constructor method key must be equal to class name to initiate default constructor policy, lookup "constructorKeys"

constructorKeys Array
default ["construct","_construct","_constructor"], add constructor body to class body

mergeConstructors Boolean
default true, allow all constructors including inherited to be merged in class constructor

inverseMergeConstructors Boolean
default false, use reversed order of super constructors

replicaConstructors Boolean
default false, allow merge of the same super constructor in diamond inheritance

constructorMap Object
default {}, inherited cache of constructors, used in "mergeConstructors" process

autoDestructor Boolean
default true, allow XeltoSS to auto destroy upon xeltoss hybridization

destructorKeys Array
default ["destruct","_destruct","_destructor"], invoke destructor upon end of xeltoss hybridization

allowSetters Boolean
default true, extract and verify defined setters into new class

allowGetters Boolean
default true, extract and verify defined getters into new class

allowAsync Boolean
default false, extract and verify defined async methods into new class

AsyncFunction Function
default null, AsyncFunction Primitive definition

allowGenerator Boolean
default false, extract and verify defined generator methods into new class

GeneratorFunction Function
default null, GeneratorFunction Primitive definition

ASTConstructor Function
default null, Abstract Syntax Tree Primitive definition, lookup "xeltoss/ASTConstructor.js"

bodyAssembler Function
default null, invoke upon every body property addition during class construction process

methodAssembler Function
default null, invoke upon every method addition during class construction process

argsLookup Function
default null, used in "getConstructorArgs"

aststruct Object
default null, defined in "buildASTObject" after calling "buildInstructions"

proxyASTBuilder Function
default null, used in "buildASTObject" as external Abstract Syntax Tree Object builder (usually Virtual Machine or source code parser)

proxyInstructions Function
default null, used in "buildInstructions"

deflat Function
default null, extract any additional information regarding instance according to deflat properties

chmod Number
default 0, used in "buildInstructions" (usually defines mode of character reading throughout source code)

Methods

initTokens() : Object
constructs "tokens" object

return XeltoSS Object, self

initKeywords() : Object
constructs "keywords" object

return XeltoSS Object, self

initOperators() : Object
constructs "operator" object

return XeltoSS Object, self

initAsync() : Object
constructs "AsyncFunction" and allows async

return XeltoSS Object, self

initGenerator() : Object
constructs "GeneratorFunction" and allows generator

return XeltoSS Object, self

updateTimers(Boolean obscure) : Object

  • obscure - Boolean, if true will remove setInterval/setTimeout otherwise will revert

return XeltoSS Object, self

hashString(String str) : String

  • str* - String, bitshifted version will be generated

return String, hash version of input str

decomposeFunction(Function f) : Array

  • f* - Function, any function

return Array, 0-name:String, 1-arguments keyname:Array, 2-function body:String, 3-hash of f body:String, 4-function header:String

deflatCls(Object obj, Object maps, Boolean interfaces, Boolean abstracts, Boolean constructs, Boolean inheritance) : Object

  • obj* - Object, object in reconstruction, instance of ProtoSS constructor or custom format
  • maps - Object, extracted polymorphic maps from "obj"
  • interfaces - Boolean, modify interfaces
  • abstracts - Boolean, modify abstract classes
  • constructs - Boolean, modify constructors
  • inheritance - Boolean, modify hierachy and its constructors
if(o.deflat){  
	o.deflat.call(o,obj,maps,interfaces,abstracts,constructs,inheritance);  
}

return XeltoSS Object, self

getConstructorArgs(Function clsconstructor, Object obj, String key, Object data) : String

  • clsconstructor* - Function, corresponding constructor in "obj" key-value
  • obj* - Object, host object
  • key* - String, key on host object
  • data - Object, additional data for "argsLookup", usually polymorphic maps
if(o.argsLookup){  
	return o.argsLookup.call(o,clsconstructor,obj,key,data);  
}

return String, arguments string representation ready for function construction

buildInstructions(String fbody, Function cls) : Array

  • fbody* - String, class source in string format
  • cls* - Function, function reference to fbody string
var fbl=fbody.length,ch=o.chmod,instr=[];  
if(fbl>0 && o.proxyInstructions){  
	return o.proxyInstructions.call(o,fbody,cls,ch,instr);  
}  
return instr;  

return Array, code instructions representing source

buildASTObject(Function cls) : Object

  • cls* - Function, uses "proxyASTBuilder" or "new" instance as default behaviour in JS VM and "buildInstructions" aststruct extraction
if(!o.proxyASTBuilder){  
	var ast=new cls();  
	o.aststruct=o.buildInstructions(cls.toString(),cls);  
	return ast;  
}  
return o.proxyASTBuilder.call(o,cls);  

return Object, default is cls instance as it is generated by JS VM

identifyKeyChain(Object obj, Function identifyKeyHandler) : Object

  • obj* - Object, host object, obtains supername string
  • identifyKeyHandler* - Function, function "nkic(obj,k,d,s)" mapped by supername

return XeltoSS Object, self

addEmbedMap(Object obj, Object keyHandlerMap) : Object

  • obj* - Object, host object, obtains supername string
  • keyHandlerMap* - Object, key-function object map, "em[sname][k](obj,k,decomp,sname)", functions can be generated with "argumentKeyMatch"

return XeltoSS Object, self

augmentKey(Object obj, Object akeyMap) : Object

  • obj* - Object, host object, obtains supername string
  • akeyMap* - Object, key-array object map, must be generated "augmentKeyMap[sname][key]=[]" using lower case keys, used in "argumentKeyMatch"

return XeltoSS Object, self

argumentKeyMatch(Number orshift, Object defval, Function formatter) : Function

  • orshift - Number, configure argument index shift upon matching it with "augmentKeyMap" by supername "s"
  • defval - Object, default value, return using "valToString" and special keyword implementations (self, this, byte, word, void), lookup "noKeyIdentificationChain"
  • formatter - Function, format upon return "formatter(kv,fkv,defval,obj,k,d,s)"

return Function, function(obj,k,d,s) used in "addEmbedMap"

valToString(Object val) : String

  • val* - Object, uses standard methods of convertion, objects and arrays may be converted using "objectStringufy" and "arrayStringify"

return String, parsed val into String, acceptable by VM as a property, i.e. class constructor property

findMethodInMaps(Object obj, String key, Function method, Array maps) : Object

  • obj* - Object, obtains maps by map key
  • key* - String, method key
  • method* - Function, method reference
  • maps* - Array, map keys in supers order

return Object, super method map owner of the method

toCls(Object obj, String clsname, String clssuper, Boolean deflat, Object polymaps, Object reservedwordsmap, Boolean emptify) : String

  • obj* - Object, ProtoSS instance or ASTObject used to construct class string
  • clsname - String, JS Class name or cls name
  • clssuper - String, JS Super class name (extends property) or none
  • deflat - Boolean, will call external deflatter to finalize property and method extraction during reconstruction phase
  • polymaps - Object, initial polymorphic references
  • reservedwordsmap - Object, default key names
  • emptify - Boolean, empty Object/Array or null values in properties

return String, class representation in String format

ClsFactoryFromStringCls(String clss) : Function

  • clss* - String, class representation in String format, will be wrapped in Function return body

return Function, factory/generator of XeltoSS class, a call is required to return class reference

toClsFactory(Object obj, String clsname, String clssuper, Boolean deflat, Object polymaps, Object reservedwordsmap, Boolean emptify) : Function

  • cls* - Function, ProtoSS class, exchange in package default to XeltoSS
  • clsname - String, JS Class name or cls name
  • clssuper - String, JS Super class name (extends property) or none
  • deflat - Boolean, will call external deflatter to finalize property and method extraction during reconstruction phase
  • polymaps - Object, initial polymorphic references
  • reservedwordsmap - Object, default key names
  • emptify - Boolean, empty Object/Array or null values in properties

return Function, factory/generator of XeltoSS class, a call is required to return class reference

toClsBlobScript(String clss, String prefix, String suffix) : HTMLElement

  • clss* - String, script body converted to blob file with url
  • prefix - String, surround prefix of script body
  • suffix - String, surround suffix of script body

return HTMLElement, script tag with blob url to js file

toClsScript(String clss, String prefix, String suffix) : HTMLElement

  • clss* - String, script body imported in tag directly
  • prefix - String, surround prefix of script body
  • suffix - String, surround suffix of script body

return HTMLElement, script tag with js body

reconstruct(Function cls, String clsname, String clssuper, Boolean deflat, Object polymaps, Object reservedwordsmap, Boolean emptify, Boolean useclsfactory) : Function

  • cls* - Function, ProtoSS class, exchange in package default to XeltoSS
  • clsname - String, JS Class name or cls name
  • clssuper - String, JS Super class name (extends property) or none
  • deflat - Boolean, will call external deflatter to finalize property and method extraction during reconstruction phase
  • polymaps - Object, initial polymorphic references
  • reservedwordsmap - Object, default key names
  • emptify - Boolean, empty Object/Array or null values in properties
  • useclsfactory - Boolean, use "toClsFactory" instead of "toClsScript"

return Function, XeltoSS class

autodestroy(Object obj) : Boolean

  • obj* - Object, if "autoDestructor" will try "destructorKeys" on obj to call destructor method

return Boolean, true=successful destroy

hybrid(Function escls, Function protcls, Object obj, Boolean swap, Object polymaps) : Object

  • escls* - Function, JS Class, any class can be converted to XeltoSS Hybrid
  • protcls* - Function, ProtoSS Class, any class can be converted to prototype class of the XeltoSS Hybrid
  • obj* - Object, ProtoSS or JS Class instance, extracts super hierarchy
  • swap - Boolean, exchange in package to XeltoSS Hybrid (JS+ProtoSS class)
  • polymaps - Object, polymorphic references as usually constructed by "toCls"

return XeltoSS Object, self

xeltoss(Function cls, String clsname, String clssuper, Boolean deflat, Object polymaps, Object reservedwordsmap, Boolean emptify, Boolean useclsfactory) : Function

  • cls* - Function, ProtoSS class, exchange in package default to XeltoSS
  • clsname - String, JS Class name or cls name
  • clssuper - String, JS Super class name (extends property) or none
  • deflat - Boolean, will call external deflatter to finalize property and method extraction during reconstruction phase
  • polymaps - Object, initial polymorphic references
  • reservedwordsmap - Object, default key names
  • emptify - Boolean, empty Object/Array or null values in properties
  • useclsfactory - Boolean, use "toClsFactory" instead of "toClsScript"

return Function, XeltoSS class

protoss(Function cls) : Function

  • cls* - Function, XeltoSS class, exchange in package default to ProtoSS

return Function, ProtoSS class

_constructor() : void

return void, creates static instance

_destructor() : void

return void, cleans static instances

Static

Properties

__InitXeltoSSPrototypes Boolean
default false, flag state of InitXeltoSSPrototypes

Methods

InitXeltoSSPrototypes(Boolean override) : XeltoSS

  • override - Boolean, mark XeltoSS Prototype for overriding, will reinstall prototypes in effect

return Function, self XeltoSS class

Object Prototype

superx(function_arguments|Array arguments, Array|Boolean call_arguments, String name) : Object

  • arguments* - (args) function arguments object if supported, or manually created Array [] with assigned "callee" reference to the function class object
  • call_arguments* - (cargs) Array used to call "apply" of the super constructor function, Boolean true will use arguments as call arguments (cargs=args)
  • name - String used to define the name of the constructor in the prototype, default __constructor

return constructor function result or "undefined" for duplicated super constructor (or no constructor)

getSuperx(Function fn, String name) : Array

  • fn - Function, if null will use this
  • name - String, if null will use __constructor

return Array, of super constructor function or functions in XeltoSS mode (if super is aggregate will use __constructor_list)

ix(Function sfn, Function fn, String name) : Boolean

  • sfn* - Function, super XeltoSS function to check against
  • fn - Function, if null will use this, to obtain all supers
  • name - String, if null will use __constructor

return Boolean, true - if it exists in the inheritance tree or equals this constructor in XeltoSS mode, otherwise false

Function Prototype

xcoped(Object scope) : Function

  • scope* - Object, usually "this" in classes or original function owner

return Function, new function wrapper calling original using scope

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.