mirror of
https://github.com/esiur/esiur-js.git
synced 2025-06-27 07:13:12 +00:00
Annotations
This commit is contained in:
@ -124,6 +124,7 @@ export default class DistributedConnection extends IStore {
|
|||||||
this.requests = new KeyList();// {};
|
this.requests = new KeyList();// {};
|
||||||
//this.pathRequests = new KeyList();// {};
|
//this.pathRequests = new KeyList();// {};
|
||||||
this.templateRequests = new KeyList();
|
this.templateRequests = new KeyList();
|
||||||
|
this.templateByNameRequests = new KeyList();
|
||||||
this.resourceRequests = new KeyList();// {};
|
this.resourceRequests = new KeyList();// {};
|
||||||
this.callbackCounter = 0;
|
this.callbackCounter = 0;
|
||||||
|
|
||||||
@ -2260,6 +2261,36 @@ export default class DistributedConnection extends IStore {
|
|||||||
return reply;
|
return reply;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getTemplateByClassName(className) {
|
||||||
|
|
||||||
|
let template = this.templates.find((x)=>x.className == className);
|
||||||
|
if (template != null)
|
||||||
|
return new AsyncReply(template);
|
||||||
|
|
||||||
|
else if (this.templateByNameRequests.contains(className))
|
||||||
|
return this.templateByNameRequests.item(className);
|
||||||
|
|
||||||
|
var reply = new AsyncReply();
|
||||||
|
this.templateByNameRequests.add(className, reply);
|
||||||
|
|
||||||
|
var self = this;
|
||||||
|
|
||||||
|
let classNameBytes = DC.stringToBytes(className);
|
||||||
|
|
||||||
|
this.sendRequest(IIPPacketAction.TemplateFromClassName)
|
||||||
|
.addUint8(classNameBytes.length)
|
||||||
|
.addUint8Array(classNameBytes)
|
||||||
|
.done()
|
||||||
|
.then(function (rt) {
|
||||||
|
self.templateByNameRequests.remove(className);
|
||||||
|
self.templates.add(rt[0].classId.valueOf(), rt[0]);
|
||||||
|
Warehouse.putTemplate(rt[0]);
|
||||||
|
reply.trigger(rt[0]);
|
||||||
|
});
|
||||||
|
|
||||||
|
return reply;
|
||||||
|
}
|
||||||
|
|
||||||
getTemplate(classId) {
|
getTemplate(classId) {
|
||||||
if (this.templates.contains(classId))
|
if (this.templates.contains(classId))
|
||||||
return new AsyncReply(this.templates.item(classId));
|
return new AsyncReply(this.templates.item(classId));
|
||||||
|
@ -145,8 +145,8 @@ export default class DistributedResource extends IResource
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// get expansion
|
// get annotation
|
||||||
func.help = self.instance.template.functions[ft.index].expansion;
|
func.help = self.instance.template.functions[ft.index].annotation;
|
||||||
return func;
|
return func;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -3,24 +3,21 @@ import MemberTemplate from './MemberTemplate.js';
|
|||||||
import Codec from '../../Data/Codec.js';
|
import Codec from '../../Data/Codec.js';
|
||||||
|
|
||||||
export default class ConstantTemplate extends MemberTemplate {
|
export default class ConstantTemplate extends MemberTemplate {
|
||||||
//final dynamic value;
|
|
||||||
//final String? expansion;
|
|
||||||
//final RepresentationType valueType;
|
|
||||||
|
|
||||||
constructor(template, index, name,
|
constructor(template, index, name,
|
||||||
inherited, valueType, value, expansion){
|
inherited, valueType, value, annotation){
|
||||||
super(template, index, name, inherited) ;
|
super(template, index, name, inherited) ;
|
||||||
this.valueType = valueType;
|
this.valueType = valueType;
|
||||||
this.value = value;
|
this.value = value;
|
||||||
this.expansion = expansion;
|
this.annotation = annotation;
|
||||||
}
|
}
|
||||||
|
|
||||||
compose() {
|
compose() {
|
||||||
var name = super.compose();
|
var name = super.compose();
|
||||||
var hdr = this.inherited ? 0x80 : 0;
|
var hdr = this.inherited ? 0x80 : 0;
|
||||||
|
|
||||||
if (this.expansion != null) {
|
if (this.annotation != null) {
|
||||||
var exp = DC.stringToBytes(this.expansion);
|
var exp = DC.stringToBytes(this.annotation);
|
||||||
hdr |= 0x70;
|
hdr |= 0x70;
|
||||||
return (BL()
|
return (BL()
|
||||||
.addUint8(hdr)
|
.addUint8(hdr)
|
||||||
|
@ -39,8 +39,8 @@ export default class EventTemplate extends MemberTemplate {
|
|||||||
|
|
||||||
if (this.listenable) hdr |= 0x8;
|
if (this.listenable) hdr |= 0x8;
|
||||||
|
|
||||||
if (this.expansion != null) {
|
if (this.annotation != null) {
|
||||||
let exp = DC.stringToBytes(this.expansion);
|
let exp = DC.stringToBytes(this.annotation);
|
||||||
hdr |= 0x50;
|
hdr |= 0x50;
|
||||||
return (BL()
|
return (BL()
|
||||||
.addUint8(hdr)
|
.addUint8(hdr)
|
||||||
@ -62,11 +62,11 @@ export default class EventTemplate extends MemberTemplate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
constructor(template, index, name, inherited, argumentType,
|
constructor(template, index, name, inherited, argumentType,
|
||||||
expansion = null, listenable = false)
|
annotation = null, listenable = false)
|
||||||
{
|
{
|
||||||
super(template, index, name, inherited) ;
|
super(template, index, name, inherited) ;
|
||||||
this.argumentType = argumentType;
|
this.argumentType = argumentType;
|
||||||
this.expansion = expansion;
|
this.annotation = annotation;
|
||||||
this.listenable = listenable;
|
this.listenable = listenable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,8 +41,8 @@ export default class FunctionTemplate extends MemberTemplate {
|
|||||||
|
|
||||||
for (var i = 0; i < this.args.length; i++) bl.addDC(this.args[i].compose());
|
for (var i = 0; i < this.args.length; i++) bl.addDC(this.args[i].compose());
|
||||||
|
|
||||||
if (this.expansion != null) {
|
if (this.annotation != null) {
|
||||||
var exp = DC.stringToBytes(this.expansion);
|
var exp = DC.stringToBytes(this.annotation);
|
||||||
bl
|
bl
|
||||||
.addInt32(exp.length)
|
.addInt32(exp.length)
|
||||||
.addDC(exp);
|
.addDC(exp);
|
||||||
@ -53,11 +53,11 @@ export default class FunctionTemplate extends MemberTemplate {
|
|||||||
return bl.toDC();
|
return bl.toDC();
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(template, index, name, inherited, args, returnType, expansion = null){
|
constructor(template, index, name, inherited, args, returnType, annotation = null){
|
||||||
super(template, index, name, inherited);
|
super(template, index, name, inherited);
|
||||||
|
|
||||||
this.args = args;
|
this.args = args;
|
||||||
this.returnType = returnType;
|
this.returnType = returnType;
|
||||||
this.expansion = expansion;
|
this.annotation = annotation;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,9 +35,9 @@ export default class PropertyTemplate extends MemberTemplate {
|
|||||||
|
|
||||||
if (this.inherited) pv |= 0x80;
|
if (this.inherited) pv |= 0x80;
|
||||||
|
|
||||||
if (this.writeExpansion != null && this.readExpansion != null) {
|
if (this.writeAnnotation != null && this.readAnnotation != null) {
|
||||||
let rexp = DC.stringToBytes(this.readExpansion);
|
let rexp = DC.stringToBytes(this.readAnnotation);
|
||||||
let wexp = DC.stringToBytes(this.writeExpansion);
|
let wexp = DC.stringToBytes(this.writeAnnotation);
|
||||||
return (BL()
|
return (BL()
|
||||||
.addUint8(0x38 | pv)
|
.addUint8(0x38 | pv)
|
||||||
.addUint8(name.length)
|
.addUint8(name.length)
|
||||||
@ -48,8 +48,8 @@ export default class PropertyTemplate extends MemberTemplate {
|
|||||||
.addInt32(rexp.length)
|
.addInt32(rexp.length)
|
||||||
.addDC(rexp))
|
.addDC(rexp))
|
||||||
.toDC();
|
.toDC();
|
||||||
} else if (this.writeExpansion != null) {
|
} else if (this.writeAnnotation != null) {
|
||||||
let wexp = DC.stringToBytes(this.writeExpansion);
|
let wexp = DC.stringToBytes(this.writeAnnotation);
|
||||||
return (BL()
|
return (BL()
|
||||||
.addUint8(0x30 | pv)
|
.addUint8(0x30 | pv)
|
||||||
.addUint8(name.length)
|
.addUint8(name.length)
|
||||||
@ -58,8 +58,8 @@ export default class PropertyTemplate extends MemberTemplate {
|
|||||||
.addInt32(wexp.length)
|
.addInt32(wexp.length)
|
||||||
.addDC(wexp))
|
.addDC(wexp))
|
||||||
.toDC();
|
.toDC();
|
||||||
} else if (this.readExpansion != null) {
|
} else if (this.readAnnotation != null) {
|
||||||
let rexp = DC.stringToBytes(this.readExpansion);
|
let rexp = DC.stringToBytes(this.readAnnotation);
|
||||||
return (BL()
|
return (BL()
|
||||||
.addUint8(0x28 | pv)
|
.addUint8(0x28 | pv)
|
||||||
.addUint8(name.length)
|
.addUint8(name.length)
|
||||||
@ -78,12 +78,12 @@ export default class PropertyTemplate extends MemberTemplate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
constructor(template, index, name,
|
constructor(template, index, name,
|
||||||
inherited, valueType, readExpansion = null, writeExpansion = null, recordable = false)
|
inherited, valueType, readAnnotation = null, writeAnnotation = null, recordable = false)
|
||||||
{
|
{
|
||||||
super(template, index, name, inherited);
|
super(template, index, name, inherited);
|
||||||
this.valueType = valueType;
|
this.valueType = valueType;
|
||||||
this.readExpansion = readExpansion;
|
this.readAnnotation = readAnnotation;
|
||||||
this.writeExpansion = writeExpansion;
|
this.writeAnnotation = writeAnnotation;
|
||||||
this.recordable = recordable;
|
this.recordable = recordable;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -344,13 +344,24 @@ export default class TypeTemplate {
|
|||||||
this.members.push(this.constants[i]);
|
this.members.push(this.constants[i]);
|
||||||
|
|
||||||
// bake it binarily
|
// bake it binarily
|
||||||
var b = BL();
|
let b = BL();
|
||||||
|
let hasClassAnnotation = template.annotation != null;
|
||||||
|
|
||||||
var cls = DC.stringToBytes(this.className);
|
var cls = DC.stringToBytes(this.className);
|
||||||
b.addUint8(this.templateType)
|
b.addUint8( (hasClassAnnotation ? 0x40 : 0 ) | this.templateType)
|
||||||
.addUint8Array(this.classId.value)
|
.addUint8Array(this.classId.value)
|
||||||
.addUint8(cls.length)
|
.addUint8(cls.length)
|
||||||
.addUint8Array(cls)
|
.addUint8Array(cls);
|
||||||
.addUint32(template.version)
|
|
||||||
|
if (hasClassAnnotation)
|
||||||
|
{
|
||||||
|
var classAnnotationBytes = DC.stringToBytes(template.annotation);
|
||||||
|
b.addUint16(classAnnotationBytes.length)
|
||||||
|
.addUint8Array(classAnnotationBytes);
|
||||||
|
this.annotation = template.annotation;
|
||||||
|
}
|
||||||
|
|
||||||
|
b.addUint32(template.version)
|
||||||
.addUint16(this.members.length);
|
.addUint16(this.members.length);
|
||||||
|
|
||||||
for (let i = 0; i < this.functions.length; i++)
|
for (let i = 0; i < this.functions.length; i++)
|
||||||
@ -400,6 +411,7 @@ export default class TypeTemplate {
|
|||||||
od.content = data.clip(offset, contentLength);
|
od.content = data.clip(offset, contentLength);
|
||||||
|
|
||||||
let hasParent = (data.getUint8(offset) & 0x80) > 0;
|
let hasParent = (data.getUint8(offset) & 0x80) > 0;
|
||||||
|
let hasClassAnnotation = (data.getUint8(offset) & 0x40) > 0;
|
||||||
|
|
||||||
od.templateType = data.getUint8(offset++) & 0xF;
|
od.templateType = data.getUint8(offset++) & 0xF;
|
||||||
|
|
||||||
@ -414,6 +426,13 @@ export default class TypeTemplate {
|
|||||||
offset += 16;
|
offset += 16;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (hasClassAnnotation) {
|
||||||
|
let len = data.getUint16(offset);
|
||||||
|
offset += 2;
|
||||||
|
od.annotation = data.getString(offset, len);
|
||||||
|
offset += len;
|
||||||
|
}
|
||||||
|
|
||||||
od.version = data.getInt32(offset);
|
od.version = data.getInt32(offset);
|
||||||
offset += 4;
|
offset += 4;
|
||||||
|
|
||||||
@ -432,8 +451,8 @@ export default class TypeTemplate {
|
|||||||
|
|
||||||
if (type == 0) // function
|
if (type == 0) // function
|
||||||
{
|
{
|
||||||
let expansion = null;
|
let annotation = null;
|
||||||
let hasExpansion = ((data.getUint8(offset++) & 0x10) == 0x10);
|
let hasAnnotation = ((data.getUint8(offset++) & 0x10) == 0x10);
|
||||||
|
|
||||||
let len = data.getUint8(offset++);
|
let len = data.getUint8(offset++);
|
||||||
let name = data.getString(offset, len);
|
let name = data.getString(offset, len);
|
||||||
@ -457,25 +476,25 @@ export default class TypeTemplate {
|
|||||||
offset += argSize;
|
offset += argSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasExpansion) // expansion ?
|
if (hasAnnotation) // annotation ?
|
||||||
{
|
{
|
||||||
var cs = data.getUint32(offset);
|
var cs = data.getUint32(offset);
|
||||||
offset += 4;
|
offset += 4;
|
||||||
expansion = data.getString(offset, cs);
|
annotation = data.getString(offset, cs);
|
||||||
offset += cs;
|
offset += cs;
|
||||||
}
|
}
|
||||||
|
|
||||||
let ft = new FunctionTemplate(od, functionIndex++, name, inherited,
|
let ft = new FunctionTemplate(od, functionIndex++, name, inherited,
|
||||||
args, dt.type, expansion);
|
args, dt.type, annotation);
|
||||||
|
|
||||||
od.functions.push(ft);
|
od.functions.push(ft);
|
||||||
}
|
}
|
||||||
else if (type == 1) // property
|
else if (type == 1) // property
|
||||||
{
|
{
|
||||||
|
|
||||||
let hasReadExpansion = ((data.getUint8(offset) & 0x8) == 0x8);
|
let hasReadAnnotation = ((data.getUint8(offset) & 0x8) == 0x8);
|
||||||
let hasWriteExpansion = ((data.getUint8(offset) & 0x10) == 0x10);
|
let hasWriteAnnotation = ((data.getUint8(offset) & 0x10) == 0x10);
|
||||||
let readExpansion, writeExpansion;
|
let readAnnotation, writeAnnotation;
|
||||||
let recordable = ((data.getUint8(offset) & 1) == 1);
|
let recordable = ((data.getUint8(offset) & 1) == 1);
|
||||||
let permission = ((data.getUint8(offset++) >> 1) & 0x3);
|
let permission = ((data.getUint8(offset++) >> 1) & 0x3);
|
||||||
let len = data.getUint8(offset++);
|
let len = data.getUint8(offset++);
|
||||||
@ -486,33 +505,33 @@ export default class TypeTemplate {
|
|||||||
|
|
||||||
offset += dt.size;
|
offset += dt.size;
|
||||||
|
|
||||||
if (hasReadExpansion) // expansion ?
|
if (hasReadAnnotation) // annotation ?
|
||||||
{
|
{
|
||||||
let cs = data.getUint32(offset);
|
let cs = data.getUint32(offset);
|
||||||
offset += 4;
|
offset += 4;
|
||||||
readExpansion = data.getString(offset, cs);
|
readAnnotation = data.getString(offset, cs);
|
||||||
offset += cs;
|
offset += cs;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasWriteExpansion) // expansion ?
|
if (hasWriteAnnotation) // annotation ?
|
||||||
{
|
{
|
||||||
let cs = data.getUint32(offset);
|
let cs = data.getUint32(offset);
|
||||||
offset += 4;
|
offset += 4;
|
||||||
writeExpansion = data.getString(offset, cs);
|
writeAnnotation = data.getString(offset, cs);
|
||||||
offset += cs;
|
offset += cs;
|
||||||
}
|
}
|
||||||
|
|
||||||
let pt = new PropertyTemplate(od, propertyIndex++, name, inherited, dt.type, readExpansion, writeExpansion, recordable);
|
let pt = new PropertyTemplate(od, propertyIndex++, name, inherited, dt.type, readAnnotation, writeAnnotation, recordable);
|
||||||
|
|
||||||
od.properties.push(pt);
|
od.properties.push(pt);
|
||||||
}
|
}
|
||||||
else if (type == 2) // Event
|
else if (type == 2) // Event
|
||||||
{
|
{
|
||||||
let hasExpansion = ((data.getUint8(offset) & 0x10) == 0x10);
|
let hasAnnotation = ((data.getUint8(offset) & 0x10) == 0x10);
|
||||||
let listenable = ((data.getUint8(offset++) & 0x8) == 0x8);
|
let listenable = ((data.getUint8(offset++) & 0x8) == 0x8);
|
||||||
let len = data.getUint8(offset++);
|
let len = data.getUint8(offset++);
|
||||||
let name = data.getString(offset, len);
|
let name = data.getString(offset, len);
|
||||||
let expansion;
|
let annotation;
|
||||||
|
|
||||||
offset += len;
|
offset += len;
|
||||||
|
|
||||||
@ -521,22 +540,22 @@ export default class TypeTemplate {
|
|||||||
offset += dt.size;
|
offset += dt.size;
|
||||||
|
|
||||||
|
|
||||||
if (hasExpansion) // expansion ?
|
if (hasAnnotation) // annotation ?
|
||||||
{
|
{
|
||||||
let cs = data.getUint32(offset);
|
let cs = data.getUint32(offset);
|
||||||
offset += 4;
|
offset += 4;
|
||||||
expansion = data.getString(offset, cs);
|
annotation = data.getString(offset, cs);
|
||||||
offset += cs;
|
offset += cs;
|
||||||
}
|
}
|
||||||
|
|
||||||
let et = new EventTemplate(od, eventIndex++, name, inherited, dt.type, expansion, listenable);
|
let et = new EventTemplate(od, eventIndex++, name, inherited, dt.type, annotation, listenable);
|
||||||
od.events.push(et);
|
od.events.push(et);
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (type == 3) // constant
|
else if (type == 3) // constant
|
||||||
{
|
{
|
||||||
let expansion = null;
|
let annotation = null;
|
||||||
let hasExpansion = ((data[offset++] & 0x10) == 0x10);
|
let hasAnnotation = ((data[offset++] & 0x10) == 0x10);
|
||||||
|
|
||||||
let name = data.getString(offset + 1, data[offset]);
|
let name = data.getString(offset + 1, data[offset]);
|
||||||
offset += data[offset] + 1;
|
offset += data[offset] + 1;
|
||||||
@ -549,16 +568,16 @@ export default class TypeTemplate {
|
|||||||
|
|
||||||
offset += parsed.size;
|
offset += parsed.size;
|
||||||
|
|
||||||
if (hasExpansion) // expansion ?
|
if (hasAnnotation) // annotation ?
|
||||||
{
|
{
|
||||||
let cs = data.getUint32(offset);
|
let cs = data.getUint32(offset);
|
||||||
offset += 4;
|
offset += 4;
|
||||||
expansion = data.getString(offset, cs);
|
annotation = data.getString(offset, cs);
|
||||||
offset += cs;
|
offset += cs;
|
||||||
}
|
}
|
||||||
|
|
||||||
let ct = new ConstantTemplate(this, constantIndex++, name, inherited,
|
let ct = new ConstantTemplate(this, constantIndex++, name, inherited,
|
||||||
dt.type, parsed.reply.result, expansion);
|
dt.type, parsed.reply.result, annotation);
|
||||||
|
|
||||||
od.constants.push(ct);
|
od.constants.push(ct);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user