-
Notifications
You must be signed in to change notification settings - Fork 0
/
crxOop.js
5483 lines (4875 loc) · 193 KB
/
crxOop.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//version: 2.6.7
/*
The MIT License (MIT)
Copyright (c) 2016 ObIb
ObIb: Ob are the first two letters of my first name, and Ib are the first two letters
of my father's father's (grandfather's) first name. I was the senior developer at Creatrix Design
Group (website: creatrix.ca. address:2764 Richmond Rd, Ottawa Ontario Canada K2B6S2), during
but not limited to the year 2014. This information is part of the license and uniquely identifies
me, the license holder.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute,
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or
substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
(function()
{
"use strict";
var gIS_BROWSER = ((typeof(window) !== 'undefined') && (typeof(window.document) !== 'undefined'));
var gCrxOop = null;
var gWindow = null;
if(resolveCrxOopInclusionAndReturnIsAlreadyIncluded())
{return;}
var gIS_STRICT_MODE = true;
var gIS_STRICT_JS_SUPPORTED = (function(){"use strict"; return !this;})();
var gIS_STRICT_JS = (gIS_STRICT_JS_SUPPORTED ? (function(){return !this;})() :
((gWindow && gWindow.CRXNS_NON_STRICT_MODE) ? false : true));
var gCODE_KEY = function(){};
var SCOPE_PRIVATE = 1;
var SCOPE_SHARED_PRIVATE = 2;
var SCOPE_PUBLIC = 3;
var SCOPE_SHARED_PUBLIC = 4;
var SCOPE_PROTECTED = 5;
var MEMBER_TYPE_VAR = 1;
var MEMBER_TYPE_FUNCTION = 2;
var HASOWN_TYPE_VAR = 1;
var HASOWN_TYPE_FUNCTION = 2;
var HASOWN_TYPE_FOREIGN = 4;
var HASOWN_SCOPE_SHARED_PUBLIC = 8;
var HASOWN_SCOPE_SHARED_PRIVATE = 16;
var HASOWN_SCOPE_PRIVATE = 32;
var DIRECTIVE_NO_PUBLIC_VARS_WRITE_DELEGATION = 1;
var gIS_USING_NEW_STATIC_SYNTAX = true;
//var MEMBER_TYPE_VIRTUAL_FUNCTION = 3;
//var MEMBER_TYPE_PURE_VIRTUAL_FUNCTION = 4;
var gSecureClassData_return = null;
var gFunc_createObject = null;
var gFunc_sealObject = (Object.seal && gIS_STRICT_MODE ? Object.seal : function(){});
var gFunc_freezeObject = (Object.freeze ? Object.freeze : function(){});
var gIsReadOnlyWriteSupported = false;
var gIsDefinePropertySufficientlySupported = false;
var gAreSettersAndGettersSupported = false;
var gIsStarted = false;
var gIsRunningTestCasesMode = false;
var gIsHalted = false;
var gHaltMessage = null;
var gClassSignatures = {}; //Class Name => Class ID
var gClassDefinitions = {}; /*Class ID => Class Non Verbose Definition. NOTE: CLASSE DEFINITIONS ARE NON VERBOSE CLASS DEFINITIONS, AND ALL
VERBOSE DEFINITIONS HAVE A CLASS DEFINITION (NON VERBOSE) ENTRY HERE. CLASSE DEFINITIONS MUST NEVER BE RETURNED TO THE USER UNLESS THE
CLASS IS THE SAME INSTNACE OF DEFINITION BY THE USER, I.E NON VERBOSE DEFNITION.*/
var gClassesWithVerboseDefinitions = {};//Class ID => Class Verbose Definition || NULL
var gCompiledClasses = {};
var gClassFriends = {}; //Class ID => Class IDs
var gClassIDCounter = 1;
var gClassFTables = {};
var gClassVTables = {};
var gClassVTables_firstOccurances = {};
var gClassVTables_lastOccurances = {};
var gClassVirtualFinalFunctions = {};
var gClassMemberScopes = {};
var gClassMemberTypes = {};
var gClassPublicStatics = {};
var gClassPrivateStatics = {};
var gClassStaticThis = {};
var gAreConstantsToBeCopiedToObjects = false;
var gCheckedClassDefinitions = {};
var gCheckedClassAdherenceToInterfaces = {};
var gClassInterfaceFullTraces = {};
var gClassInterfaceTraces = {};
var gInterfaceSignatures = {};
var gInterfaceIDCounter = 1;
var gInterfaceDefinitions = {}; //Interface ID => Interface Definition
var gInterfaceBuilds = {};
var gParsingData = {};
//STRUCTURES: START
var gStructureSignatures = {};
var gStructureDefinitions = {};
var gStructuresWithVerboseDefinitions = {};
var gCompiledStructures = {};
var gStructureIDCounter = 1;
var gStructureFTables = {};
var gStructureMemberScopes = {};
var gStructureMemberTypes = {};
var gStructureHasOwnIndex = {};
var gCheckedStructureDefinitions = {};
var gStructureParsingData = {};
var gStructurePrototypes = {};
//STRUCTURES: END
var gFunc_log = function(pMessage, pLevel){g_Func_log("CrxOop ==> " + pMessage, pLevel);};
var g_Func_log = function(pMessage, pLevel)
{
var vWindow = (gWindow || global);
if(vWindow && vWindow.console && vWindow.console.log)
{vWindow.console.log(pMessage);}
};
var gNamesOfTypes =
{
"[object Boolean]": "boolean",
"[object Number]": "number",
"[object String]": "string",
"[object Function]": "function",
"[object Array]": "array",
"[object Date]": "date",
"[object RegExp]": "regexp",
"[object Object]": "object",
"[object Error]": "error"
};
var gStaticContext = [null, null];
var gStackOfIsConstructorCalled = [];
var gIsConstructorCalled = {};
var gStackOfIsConstructorCalled_structures = [];
var gIsConstructorCalled_structures = {};
var gTestObject = {};
var gTraceKitReport = null;
var gStackKitHandler = null;
//var gTraceKitError = "";
var gError_start = null;
var gError_end = null;
var gWereCodeBoundriesEvaluated = false;
function resolveCrxOopInclusionAndReturnIsAlreadyIncluded()
{
var vReturn = false;
if(gIS_BROWSER)
{
if(window.crx_registerClass)
{vReturn = true;}
else
{
gCrxOop = {};
gWindow = window;
}
}
else
{
var tSymbol = Symbol['for']("225e78bc-206d-4319-aff0-68bb2796b931");
var tGlobalSymbols = Object.getOwnPropertySymbols(global);
if(tGlobalSymbols.indexOf(tSymbol) > -1)
{
vReturn = true;
module.exports = global[tSymbol];
}
else
{
gCrxOop = {};
global[tSymbol] = gCrxOop;
module.exports = gCrxOop;
if(typeof(global['window']) !== 'undefined')
{gWindow = global.window;}
}
}
return vReturn;
}
if(!Object.create)
{
gFunc_createObject = function(vPrototype)
{
function t(){};
t.prototype = vPrototype;
return new t();
}
}
else
{gFunc_createObject = Object.create;}
if(Object.defineProperty)
{
var tObject = {};
try
{
Object.defineProperty(tObject, 's', {value: 'd', writable: false});
gIsReadOnlyWriteSupported = true;
gIsDefinePropertySufficientlySupported = true;
gAreSettersAndGettersSupported = true;
}
catch(tE)
{}
}
function _eTest(){if(!gTestObject.x){gIS_STRICT_JS = true};}
function _eTest2(){return (_eTest2.caller === _eTest);}
if(gIsReadOnlyWriteSupported && !gIS_STRICT_JS)
{
Object.defineProperty(gTestObject, "x",
{
get: _eTest2,
set: function(){},
enumerable: true
});
_eTest();
}
if(!gIsReadOnlyWriteSupported && !gIS_STRICT_JS && !gIS_USING_NEW_STATIC_SYNTAX)
{halt('CURRENT BROWSER IS NOT SUPPORTED IN NON STRICT MODE');}
if(gIS_STRICT_MODE && !gIsReadOnlyWriteSupported)
{gAreConstantsToBeCopiedToObjects = true;}
function getType(pObject)
{
if(pObject == null)
{return (pObject + "");}
return (((typeof(pObject) === "object") || (typeof(pObject) === "function")) ?
(gNamesOfTypes[Object.prototype.toString.call(pObject)] || "object") : (typeof(pObject)));
}
if(gIS_BROWSER && window.TraceKit && window.TraceKit.report && window.TraceKit.report.subscribe)
{
gStackKitHandler = function(pError)
{
if((pError.message === 'CrxOop::start') || (pError.message === 'CrxOop::end'))
{
var tObject = null;
if(pError.stack && (getType(pError.stack) === 'array') && pError.stack.length > 0)
{
tObject = {"fileName": (pError.stack[0].url ? pError.stack[0].url.toLowerCase() : null),
"line": (pError.stack[0].line ? pError.stack[0].line : -1),
"column": (pError.stack[0].column ? pError.stack[0].column : -1)};
}
else
{tObject = {};}
if((pError.message === 'CrxOop::start') && (gError_start === null))
{gError_start = tObject ;}
else if((pError.message === 'CrxOop::end') && (gError_end === null))
{
gError_end = tObject;
gWereCodeBoundriesEvaluated = true;
}
}
else
{
var vMessage = "";
if(pError.message)
{g_Func_log(pError.message, 0);}
if(pError.stack && (getType(pError.stack) === 'array'))
{
vMessage = "CrxOop: Stack Trace \n";
for(var tI = 0; tI < pError.stack.length; tI++)
{
if(!gTraceKitReport_isToSkipErrorOutPut((pError.stack[tI].url ? pError.stack[tI].url : null),
(pError.stack[tI].line ? pError.stack[tI].line : null),
(pError.stack[tI].column ? pError.stack[tI].column : null)))
{
vMessage += pError.stack[tI].url + " :: ln<" + pError.stack[tI].line +
(pError.stack[tI].column ? ":" + pError.stack[tI].column : "") + ">";
if(pError.stack[tI].func && (pError.stack[tI].func !== '?'))
{
vMessage += " => " + pError.stack[tI].func;
}
vMessage += "\n";
}
}
}
window.TraceKit.report.unsubscribe(gStackKitHandler);
g_Func_log(vMessage, 0);
}
};
gTraceKitReport = function(pString)
{
var vReturn = null;
window.TraceKit.report.subscribe(gStackKitHandler);
try
{window.TraceKit.report(pString);}
catch(tE)
{vReturn = tE;}
/*window.TraceKit.report(pString);
//vReturn = gTraceKitError;
//gTraceKitError = "";
//if(vReturn)
//{return pString;}*/
};
}
else if(gIS_BROWSER && window.StackTrace && window.StackTrace.get && window.StackTrace.fromError)
{
gTraceKitReport = function(pError, pMessage)
{
if((pError.message === 'CrxOop::start') || (pError.message === 'CrxOop::end'))
{
window.StackTrace.fromError(pError).then(function(pError2)
{
var tObject = null;
if(pError2.length > 0)
{
tObject = {"fileName": (pError2[0].fileName ? pError2[0].fileName.toLowerCase() : null),
"line": (pError2[0].lineNumber ? pError2[0].lineNumber : -1),
"column": (pError2[0].columnNumber ? pError2[0].columnNumber : -1)};
}
if((pError.message === 'CrxOop::start') && (gError_start === null))
{gError_start = tObject;}
else if((pError.message === 'CrxOop::end') && (gError_end === null))
{
gError_end = tObject;
gWereCodeBoundriesEvaluated = true;
}
//g_Func_log(vMessage, 0);
})['catch'](function(pError2)
{
});
}
else
{
window.StackTrace.fromError(pError).then(function(pError)
{
var vMessage = pMessage + '\n' + "CrxOop: Stack Trace \n";
for(var tI = 0; tI < pError.length; tI++)
{
if(!gTraceKitReport_isToSkipErrorOutPut((pError[tI].fileName ? pError[tI].fileName : null),
(pError[tI].lineNumber ? pError[tI].lineNumber : null),
(pError[tI].columnNumber ? pError[tI].columnNumber : null)))
{
vMessage += pError[tI].fileName + " :: ln<" + pError[tI].lineNumber +
(pError[tI].columnNumber ? ":" + pError[tI].columnNumber : "") + ">\t";
if(pError[tI].functionName)
{
vMessage += " => " + pError[tI].functionName;
}
vMessage += "\n";
}
}
g_Func_log(vMessage, 0);
})['catch'](function(pError)
{
//g_Func_log(pError, 0);
});
}
};
}
else
{
gTraceKitReport = function(pError, pMessage)
{
var tRegExp = new RegExp(".*?[\\(\\[\\s\\:](\\d+)([:]+(\\d*))?.*");
var tRegExp2 = new RegExp(".+[\\/\\\\]([^\\/\\\\]+\\.js)[^a-zA-Z\\\"\\']*");
if((pError.message === 'CrxOop::start') || (pError.message === 'CrxOop::end'))
{
var tObject = null;
var vMessage = "" + pError.stack || pError.stacktrace;
var tTrace = [];
if(vMessage.length > 0)
{tTrace = vMessage.split('\n');}
if(tTrace.length > 0)
{
var tMatches = tRegExp.exec(tTrace[0]);
var tMatches2 = tRegExp2.exec(tTrace[0]);
if(!tMatches && !tMatches2 && (tTrace.length > 1) && ((tTrace[0].indexOf('CrxOop::start') >= 0) ||
(tTrace[0].indexOf('CrxOop::end') >= 0)))
{
tMatches = tRegExp.exec(tTrace[1]);
tMatches2 = tRegExp2.exec(tTrace[1]);
}
tObject = {"fileName": ((tMatches2 && tMatches2[1]) ? tMatches2[1].toLowerCase() : null),
"line": ((tMatches && tMatches[1]) ? parseInt(tMatches[1]) : -1),
"column": ((tMatches && tMatches[3]) ? parseInt(tMatches[3]) : -1)};
tObject["line"] = (tObject["line"] ? tObject["line"] : -1);
tObject["column"] = (tObject["column"] ? tObject["column"] : -1);
}
if((pError.message === 'CrxOop::start') && (gError_start === null))
{gError_start = tObject;}
else if((pError.message === 'CrxOop::end') && (gError_end === null))
{
gError_end = tObject;
gWereCodeBoundriesEvaluated = true;
}
}
else
{
if(gIS_BROWSER)
{
setTimeout(function()
{
gTraceKitReport_produceMessage(pError, pMessage, tRegExp, tRegExp2);
}, 1);
}
else
{return gTraceKitReport_produceMessage(pError, pMessage, tRegExp, tRegExp2);}
}
}
}
try{throw new Error('CrxOop::start');}catch(tE){gTraceKitReport(tE);}
function gTraceKitReport_produceMessage(pError, pMessage, pRegExp, pRegExp2)
{
var vMessage = "" + (pError.stack || pError.stacktrace || "");
if(vMessage.length > 0)
{
var tTrace = vMessage.split('\n');
vMessage = "";
for(var tI = 0; tI < tTrace.length; tI++)
{
if(tTrace[tI] && (tTrace[tI].toLowerCase().indexOf("crxoop.") >= 0))
{continue;}
var vIsToSkip = false;
var tMatches = pRegExp.exec(tTrace[tI]);
var tMatches2 = pRegExp2.exec(tTrace[tI]);
if(!gTraceKitReport_isToSkipErrorOutPut(((tMatches2 && tMatches2[1]) ? tMatches2[1] : null),
((tMatches && tMatches[1]) ? tMatches[1] : null),
((tMatches && tMatches[3]) ? tMatches[3] : null)))
{vMessage += tTrace[tI] + '\n';}
}
g_Func_log("\n" + pMessage + "\n" + "CrxOop: Stack Trace \n" + vMessage, 0);
return "\n" + pMessage + "\n" + "CrxOop: Stack Trace \n" + vMessage;
}
else
{return "\n" + pMessage + "\n";}
}
function gTraceKitReport_isToSkipErrorOutPut(pFileName, pLine, pColumn)
{
var vReturn = false;
if(gError_start && gError_end)
{
if(pFileName)
{
if(gError_start.fileName === pFileName.toLowerCase())
{
if((gError_start.line !== -1) && (gError_end.line !== -1) && pLine)
{
if((pLine >= gError_start.line) && (pLine <= gError_end.line))
{
if((gError_start.line === gError_end.line) && (gError_start.column !== -1) &&
(gError_end.column !== -1) && pColumn)
{
if((pColumn >= gError_start.column) &&
(pColumn <= gError_end.column))
{vReturn = true;}
}
else
{vReturn = true;}
}
}
else
{vReturn = true;}
}
}
}
else if(pFileName)
{
if(pFileName.toLowerCase().indexOf("crxoop.") >= 0)
{vReturn = true;}
}
return vReturn;
}
function registerClass(pClassName, pClassDefinition)
{
if(gIsHalted){return;}
gIsStarted = true;
if(gClassSignatures.hasOwnProperty(pClassName) ||
gInterfaceSignatures.hasOwnProperty(pClassName) ||
gStructureSignatures.hasOwnProperty(pClassName))
{halt("Interface or Class or Structure with name '" + pClassName + "' already declared", -1);}
if(!pClassDefinition.CRX_CLASS_ID)
{
pClassDefinition.CRX_DEFINITION = true;
pClassDefinition.CRX_CLASS_ID = gClassIDCounter;
pClassDefinition.CRX_CLASS_NAME = pClassName;
if((pClassDefinition.CRX_DEFINITION !== true) || (pClassDefinition.CRX_CLASS_ID !== pClassDefinition.CRX_CLASS_ID) ||
(pClassDefinition.CRX_CLASS_NAME !== pClassName) || (pClassDefinition.CRX_INTERFACE_ID !== void(0)))
{halt("UNKNOWN ERROR IN DEFINITION OF CLASS '" + pClassName + "'", -1);}
gFunc_freezeObject(pClassDefinition);
inspectClassDefinition_processVerboseDefinition(pClassDefinition);
gClassIDCounter = gClassIDCounter + 1;
}
gClassSignatures[pClassName] = pClassDefinition.CRX_CLASS_ID;
}
function getClassDefinition(pClassDefinitionOrClassName, pIsToNotRegister)
{
if(gIsHalted){return;}
if(typeof(pClassDefinitionOrClassName) === "string")
{
if(!gClassSignatures[pClassDefinitionOrClassName])
{return null;}
else
{
return (gClassDefinitions[gClassSignatures[pClassDefinitionOrClassName]] || null);
}
}
else if((pClassDefinitionOrClassName === null) || (typeof(pClassDefinitionOrClassName) !== "object") ||
(pClassDefinitionOrClassName.CRX_INTERFACE_ID !== void(0)) ||
(pClassDefinitionOrClassName.CRX_STRUCTURE_ID !== void(0)))
{return null;}
else
{
if(!pClassDefinitionOrClassName.CRX_CLASS_ID && !pIsToNotRegister)
{
pClassDefinitionOrClassName.CRX_DEFINITION = true;
pClassDefinitionOrClassName.CRX_CLASS_ID = gClassIDCounter;
if((pClassDefinitionOrClassName.CRX_DEFINITION !== true) ||
(pClassDefinitionOrClassName.CRX_CLASS_ID !== pClassDefinitionOrClassName.CRX_CLASS_ID))
{halt("UNKNOWN ERROR IN DEFINITION OF CLASS '$C" + gClassIDCounter + "'");}
gFunc_freezeObject(pClassDefinitionOrClassName);
inspectClassDefinition_processVerboseDefinition(pClassDefinitionOrClassName);
gClassIDCounter = gClassIDCounter + 1;
}
return gClassDefinitions[pClassDefinitionOrClassName.CRX_CLASS_ID];
}
}
function getClassID(pClassDefinitionOrClassName)
{
if(gIsHalted){return;}
if(typeof(pClassDefinitionOrClassName) === "string")
{return (gClassSignatures[pClassDefinitionOrClassName] || null);}
return (pClassDefinitionOrClassName.CRX_CLASS_ID || null);
}
function getClassNameOrID(pClass)
{
if(pClass.CRX_CLASS_NAME)
{return pClass.CRX_CLASS_NAME;}
if(pClass.CRX_CLASS_ID)
{return "$C" + pClass.CRX_CLASS_ID;}
return null;
}
function registerInterface(pInterfaceName, pInterface)
{
if(gIsHalted){return;}
gIsStarted = true;
if(gClassSignatures.hasOwnProperty(pInterfaceName) ||
gInterfaceSignatures.hasOwnProperty(pInterfaceName) ||
gStructureSignatures.hasOwnProperty(pInterfaceName))
{halt("Interface or Class or Structure with name '" + pInterfaceName + "' already declared", -1);}
if(!pInterface.CRX_INTERFACE_ID)
{
pInterface.CRX_DEFINITION = true;
pInterface.CRX_INTERFACE_ID = gInterfaceIDCounter;
pInterface.CRX_INTERFACE_NAME = pInterfaceName;
if((pInterface.CRX_DEFINITION !== true) || (pInterface.CRX_INTERFACE_ID !== gInterfaceIDCounter) ||
(pInterface.CRX_INTERFACE_NAME !== pInterfaceName) ||
(pInterface.CRX_CLASS_ID !== void(0)))
{halt("UNKNOWN ERROR IN DEFINITION OF INTERFACE '" + pInterfaceName + "'", -1);}
gFunc_freezeObject(pInterface);
gInterfaceDefinitions[gInterfaceIDCounter] = pInterface;
gInterfaceIDCounter = gInterfaceIDCounter + 1;
}
gInterfaceSignatures[pInterfaceName] = pInterface.CRX_INTERFACE_ID;
}
function getInterface(pInterfaceOrInterfaceName)
{
if(gIsHalted){return;}
if(typeof(pInterfaceOrInterfaceName) === "string")
{
if(!gInterfaceSignatures[pInterfaceOrInterfaceName])
{return null;}
else
{return (gInterfaceDefinitions[gInterfaceSignatures[pInterfaceOrInterfaceName]] || null);}
}
else if((pInterfaceOrInterfaceName === null) || (typeof(pInterfaceOrInterfaceName) !== "object") ||
(pInterfaceOrInterfaceName.CRX_CLASS_ID !== void(0)) ||
(pInterfaceOrInterfaceName.CRX_STRUCTURE_ID !== void(0)))
{return null;}
else
{
if(!pInterfaceOrInterfaceName.CRX_INTERFACE_ID)
{
pInterfaceOrInterfaceName.CRX_DEFINITION = true;
pInterfaceOrInterfaceName.CRX_INTERFACE_ID = gInterfaceIDCounter;
if((pInterfaceOrInterfaceName.CRX_DEFINITION !== true) ||
(pInterfaceOrInterfaceName.CRX_INTERFACE_ID !== gInterfaceIDCounter))
{halt("UNKNOWN ERROR IN DEFINITION OF INTERFACE '$I" + gInterfaceIDCounter + "'", -1);}
gFunc_freezeObject(pInterfaceOrInterfaceName);
gInterfaceDefinitions[gInterfaceIDCounter] = pInterfaceOrInterfaceName;
gInterfaceIDCounter = gInterfaceIDCounter + 1;
}
return gInterfaceDefinitions[pInterfaceOrInterfaceName.CRX_INTERFACE_ID];
}
}
function getInterfaceID(pInterfaceOrInterfaceName)
{
if(gIsHalted){return;}
if(typeof(pInterfaceOrInterfaceName) === "string")
{return (gInterfaceSignatures[pInterfaceOrInterfaceName] || null);}
return (pInterfaceOrInterfaceName.CRX_INTERFACE_ID || null);
}
function getInterfaceNameOrID(pInterface)
{
if(pInterface.CRX_INTERFACE_NAME)
{return pInterface.CRX_INTERFACE_NAME;}
if(pInterface.CRX_INTERFACE_ID)
{return "$I" + pInterface.CRX_INTERFACE_ID;}
return null;
}
function registerStructure(pStructureName, pStructure)
{
if(gIsHalted){return;}
gIsStarted = true;
if(gClassSignatures.hasOwnProperty(pStructureName) ||
gInterfaceSignatures.hasOwnProperty(pStructureName) ||
gStructureSignatures.hasOwnProperty(pStructureName))
{halt("Interface or Class or Structure with name '" + pStructureName + "' already declared", -1);}
if(!pStructure.CRX_STRUCTURE_ID)
{
pStructure.CRX_DEFINITION = true;
pStructure.CRX_STRUCTURE_ID = gStructureIDCounter;
pStructure.CRX_STRUCTURE_NAME = pStructureName;
if((pStructure.CRX_DEFINITION !== true) || (pStructure.CRX_STRUCTURE_ID !== gStructureIDCounter) ||
(pStructure.CRX_STRUCTURE_NAME !== pStructureName) ||
(pStructure.CRX_CLASS_ID !== void(0)) ||
(pStructure.CRX_INTERFACE_ID !== void(0)))
{halt("UNKNOWN ERROR IN DEFINITION OF STRUCTRE '" + pStructureName + "'", -1);}
gFunc_freezeObject(pStructure);
gStructureDefinitions[gStructureIDCounter] = pStructure;
gStructureIDCounter = gStructureIDCounter + 1;
}
gStructureSignatures[pStructureName] = pStructure.CRX_STRUCTURE_ID;
}
function getStructureDefinition(pStructureOrStructureName, pIsToNotRegister)
{
if(gIsHalted){return;}
if(typeof(pStructureOrStructureName) === "string")
{
if(!gStructureSignatures[pStructureOrStructureName])
{return null;}
else
{return (gStructureDefinitions[gStructureSignatures[pStructureOrStructureName]] || null);}
}
else if((pStructureOrStructureName === null) || (typeof(pStructureOrStructureName) !== "object") ||
(pStructureOrStructureName.CRX_CLASS_ID !== void(0)) ||
(pStructureOrStructureName.CRX_INTERFACE_ID !== void(0)))
{return null;}
else
{
if(!pStructureOrStructureName.CRX_STRUCTURE_ID && !pIsToNotRegister)
{
pStructureOrStructureName.CRX_DEFINITION = true;
pStructureOrStructureName.CRX_STRUCTURE_ID = gStructureIDCounter;
if((pStructureOrStructureName.CRX_DEFINITION !== true) ||
(pStructureOrStructureName.CRX_STRUCTURE_ID !== gStructureIDCounter))
{halt("UNKNOWN ERROR IN DEFINITION OF INTERFACE '$I" + gStructureIDCounter + "'");}
gFunc_freezeObject(pStructureOrStructureName);
gStructureDefinitions[gStructureIDCounter] = pStructureOrStructureName;
gStructureIDCounter = gStructureIDCounter + 1;
}
return gStructureDefinitions[pStructureOrStructureName.CRX_STRUCTURE_ID];
}
}
function getStructureID(pStructureOrStructureName)
{
if(gIsHalted){return;}
if(typeof(pStructureOrStructureName) === "string")
{return (gStructureSignatures[pStructureOrStructureName] || null);}
return (pStructureOrStructureName.CRX_STRUCTURE_ID || null);
}
function getStructureNameOrID(pStructure)
{
if(pStructure.CRX_STRUCTURE_NAME)
{return pStructure.CRX_STRUCTURE_NAME;}
if(pStructure.CRX_STRUCTURE_ID)
{return "$S" + pStructure.CRX_STRUCTURE_ID;}
return null;
}
/*function _new(pClassDefinitionOrClassName, pParameter01, pParameter02, ...)*/
/*function _new(pStructureDefinitionOrStructureName, pParameter01, pParameter02, ...)*/
/*function _new(pLength, pClassDefinitionOrClassName, pParameter01, pParameter02, ...)*/
/*function _new(pLength, pStructureDefinitionOrStructureName, pParameter01, pParameter02, ...)*/
/*function _new(pLength, pParametersArray, pClassDefinitionOrClassName)*/
/*function _new(pLength, pParametersArray, pStructureDefinitionOrStructureName)*/
/*function _new(pLength, pParametersFunction, pClassDefinitionOrClassName)*/
/*function _new(pLength, pParametersFunction, pStructureDefinitionOrStructureName)*/
function _new(pParameter1, pParameter2, pParameter3)
{
if(gIsHalted){return;}
var vIS_ARRAY_MODE = false;
var vClass = null;
var vStructure = null;
var vObjects = [];
var vLength = -1;
var vParameters = null;
var vClassOrStructureDefinitionOrNameFromParameters = null;
var vTypeOfParameter2 = getType(pParameter2);
var tI = 0;
gIsStarted = true;
if(typeof(pParameter1) === "number")
{
vIS_ARRAY_MODE = true;
vLength = Math.abs(pParameter1);
if((vTypeOfParameter2 !== 'array') && (vTypeOfParameter2 !== 'function'))
{
vClassOrStructureDefinitionOrNameFromParameters = pParameter2;
vClass = getClassDefinition(pParameter2);
if(vClass === null)
{vStructure = getStructureDefinition(pParameter2);}
vParameters = Array.prototype.slice.call(arguments, 2);
}
else
{
if((vTypeOfParameter2 === 'array') && (pParameter2.length < 1))
{return null;}
vClassOrStructureDefinitionOrNameFromParameters = pParameter3;
vClass = getClassDefinition(pParameter3);
if(vClass === null)
{vStructure = getStructureDefinition(pParameter3);}
vParameters = pParameter2;
}
}
else
{
vClassOrStructureDefinitionOrNameFromParameters = pParameter1;
vClass = getClassDefinition(pParameter1);
if(vClass === null)
{vStructure = getStructureDefinition(pParameter1);}
vLength = 1;
vParameters = Array.prototype.slice.call(arguments, 1);
}
if((vClass === null) && (vStructure === null))
{halt("UNABLE TO RESOLVE CLASS/STRUCTURE \"" + vClassOrStructureDefinitionOrNameFromParameters + "\"DURING CALL TO crx_new", -1);}
if(vStructure === null)
{
var tCRX_CLASS_INFOs = [];
gStackOfIsConstructorCalled.push(gIsConstructorCalled);
gIsConstructorCalled = {};
for(tI = 0; tI < vLength; tI++)
{tCRX_CLASS_INFOs[tI] = {};}
prepareClass(vClass);
if(gIsHalted){return null;}
if(gParsingData[vClass.CRX_CLASS_ID].remainingAbstractVirtuals.length > 0)
{
var tRestOfMessage = "";
var tIsNotFirst = false;
for(tKey in gParsingData[vClass.CRX_CLASS_ID].remainingAbstractVirtuals.p)
{
if(!gParsingData[vClass.CRX_CLASS_ID].remainingAbstractVirtuals.p.hasOwnProperty(tKey))
{continue;}
tRestOfMessage += (tIsNotFirst ? ", \"" : "\"") + tKey + "()\"";
tIsNotFirst = true;
}
halt("CAN NOT CREATE INSTANCE OF ABSTRACT CLASS \"" + getClassNameOrID(vClass) + "\". MISSING IMPLEMENTATIONS FOR FUNCTIONS " + tRestOfMessage, -1);
}
vObjects = _new_build(gCompiledClasses[vClass.CRX_CLASS_ID], tCRX_CLASS_INFOs, /*{p: false},*/ vLength);
if(vObjects.length === 0)
{halt("UNKNOWN ERROR DURING CALL TO crx_new", -1);}
for(var tKey in gClassVTables[vClass.CRX_CLASS_ID])
{
if(!gClassVTables[vClass.CRX_CLASS_ID].hasOwnProperty(tKey))
{continue;}
for(tI = 0; tI < vLength; tI++)
{
setObjectReadOnlyMember(tCRX_CLASS_INFOs[tI].
CRX_OBJECT_SEGMENTS[gClassVTables_firstOccurances[
vClass.CRX_CLASS_ID][tKey]], tKey, ftable_this_call__virtual(vClass.CRX_CLASS_ID, "puv", tKey));
}
}
if(vObjects[0].CONSTRUCT)
{
try
{
if(!vIS_ARRAY_MODE)
{
vObjects[0].CONSTRUCT.apply(vObjects[0], vParameters);
gIsConstructorCalled[vObjects[0].CRX_CLASS_ID] = false;
delete(vObjects[0].CONSTRUCT);
}
else
{
if(vTypeOfParameter2 === "function")
{
for(tI = 0; tI < vLength; tI++)
{
vObjects[tI].CONSTRUCT.apply(vObjects[tI], vParameters(tI));
gIsConstructorCalled[vObjects[0].CRX_CLASS_ID] = false;
}
}
else if(vTypeOfParameter2 === "array")
{
var tLength = vParameters.length;
for(tI = 0; tI < vLength; tI++)
{
if(tI < tLength)
{vObjects[tI].CONSTRUCT.apply(vObjects[tI], vParameters[tI]);}
else
{vObjects[tI].CONSTRUCT.apply(vObjects[tI], vParameters[tLength - 1]);}
gIsConstructorCalled[vObjects[0].CRX_CLASS_ID] = false;
}
}
else
{
for(tI = 0; tI < vLength; tI++)
{
vObjects[tI].CONSTRUCT.apply(vObjects[tI], vParameters);
gIsConstructorCalled[vObjects[0].CRX_CLASS_ID] = false;
}
}
for(tI = 0; tI < vLength; tI++)
{delete(vObjects[tI].CONSTRUCT);}
gIsConstructorCalled[vObjects[0].CRX_CLASS_ID] = false;
}
}
catch(tE)
{halt('CONSTRUCTION OF CLASS \"' + getClassNameOrID(vClass) + '\" THREW AN EXCEPTION: ' + tE, tE);}
}
for(tI = 0; tI < vLength; tI++)
{tCRX_CLASS_INFOs[tI].CRX_CLASS_ID = vClass.CRX_CLASS_ID;}
if(gIS_STRICT_MODE)
{
for(var tKey in tCRX_CLASS_INFOs[0].CRX_OBJECT_SEGMENTS)
{
if(!tCRX_CLASS_INFOs[0].CRX_OBJECT_SEGMENTS.hasOwnProperty(tKey))
{continue;}
for(tI = 0; tI < vLength; tI++)
{gFunc_sealObject(tCRX_CLASS_INFOs[tI].CRX_OBJECT_SEGMENTS[tKey]);}
}
}
gIsConstructorCalled = gStackOfIsConstructorCalled.pop();
if(!vIS_ARRAY_MODE)
{return vObjects[0];}
else
{return vObjects;}
}
else
{
var tCRX_STRUCTURE_INFOs = [];
gStackOfIsConstructorCalled_structures.push(gIsConstructorCalled_structures);
gIsConstructorCalled_structures = {};
for(tI = 0; tI < vLength; tI++)
{tCRX_STRUCTURE_INFOs[tI] = {};}
prepareStructure(vStructure);
if(gIsHalted){return null;}
vObjects = _new_buildStructure(gCompiledStructures[vStructure.CRX_STRUCTURE_ID], tCRX_STRUCTURE_INFOs, vLength);
if(vObjects.length === 0)
{halt("UNKNOWN ERROR DURING CALL TO crx_new", -1);}
if(gCompiledStructures[vStructure.CRX_STRUCTURE_ID].PUBLIC && gCompiledStructures[vStructure.CRX_STRUCTURE_ID].PUBLIC_CONSTRUCT)
{
try
{
if(!vIS_ARRAY_MODE)
{
gCompiledStructures[vStructure.CRX_STRUCTURE_ID].PUBLIC_CONSTRUCT.apply(vObjects[0], vParameters);
gIsConstructorCalled_structures[vStructure.CRX_STRUCTURE_ID] = false;
delete(tCRX_STRUCTURE_INFOs[0].CRX_SHARED_SEGMENT.CONSTRUCT);
}
else
{
if(vTypeOfParameter2 === "function")
{
for(tI = 0; tI < vLength; tI++)
{
gCompiledStructures[vStructure.CRX_STRUCTURE_ID].PUBLIC_CONSTRUCT.apply(vObjects[tI], vParameters(tI));
gIsConstructorCalled_structures[vStructure.CRX_STRUCTURE_ID] = false;
}
}
else if(vTypeOfParameter2 === "array")
{
var tLength = vParameters.length;
for(tI = 0; tI < vLength; tI++)
{
if(tI < tLength)
{gCompiledStructures[vStructure.CRX_STRUCTURE_ID].PUBLIC_CONSTRUCT.apply(vObjects[tI], vParameters[tI]);}
else
{gCompiledStructures[vStructure.CRX_STRUCTURE_ID].PUBLIC_CONSTRUCT.apply(vObjects[tI], vParameters[tLength - 1]);}
gIsConstructorCalled_structures[vStructure.CRX_STRUCTURE_ID] = false;
}
}
else
{
for(tI = 0; tI < vLength; tI++)
{
gCompiledStructures[vStructure.CRX_STRUCTURE_ID].PUBLIC_CONSTRUCT.apply(vObjects[tI], vParameters);
gIsConstructorCalled_structures[vStructure.CRX_STRUCTURE_ID] = false;
}
}
for(tI = 0; tI < vLength; tI++)
{delete(tCRX_STRUCTURE_INFOs[tI].CRX_SHARED_SEGMENT.CONSTRUCT);}
gIsConstructorCalled_structures[vStructure.CRX_STRUCTURE_ID] = false;
}
}