Built motion from commit 6a09e18b.|2.6.11
[motion2.git] / legacy-libs / grpc-cloned / node_modules / protobufjs / src / ProtoBuf / Reflect / T.js
1 /**\r
2  * Constructs a Reflect base class.\r
3  * @exports ProtoBuf.Reflect.T\r
4  * @constructor\r
5  * @abstract\r
6  * @param {!ProtoBuf.Builder} builder Builder reference\r
7  * @param {?ProtoBuf.Reflect.T} parent Parent object\r
8  * @param {string} name Object name\r
9  */\r
10 var T = function(builder, parent, name) {\r
11 \r
12     /**\r
13      * Builder reference.\r
14      * @type {!ProtoBuf.Builder}\r
15      * @expose\r
16      */\r
17     this.builder = builder;\r
18 \r
19     /**\r
20      * Parent object.\r
21      * @type {?ProtoBuf.Reflect.T}\r
22      * @expose\r
23      */\r
24     this.parent = parent;\r
25 \r
26     /**\r
27      * Object name in namespace.\r
28      * @type {string}\r
29      * @expose\r
30      */\r
31     this.name = name;\r
32 \r
33     /**\r
34      * Fully qualified class name\r
35      * @type {string}\r
36      * @expose\r
37      */\r
38     this.className;\r
39 };\r
40 \r
41 /**\r
42  * @alias ProtoBuf.Reflect.T.prototype\r
43  * @inner\r
44  */\r
45 var TPrototype = T.prototype;\r
46 \r
47 /**\r
48  * Returns the fully qualified name of this object.\r
49  * @returns {string} Fully qualified name as of ".PATH.TO.THIS"\r
50  * @expose\r
51  */\r
52 TPrototype.fqn = function() {\r
53     var name = this.name,\r
54         ptr = this;\r
55     do {\r
56         ptr = ptr.parent;\r
57         if (ptr == null)\r
58             break;\r
59         name = ptr.name+"."+name;\r
60     } while (true);\r
61     return name;\r
62 };\r
63 \r
64 /**\r
65  * Returns a string representation of this Reflect object (its fully qualified name).\r
66  * @param {boolean=} includeClass Set to true to include the class name. Defaults to false.\r
67  * @return String representation\r
68  * @expose\r
69  */\r
70 TPrototype.toString = function(includeClass) {\r
71     return (includeClass ? this.className + " " : "") + this.fqn();\r
72 };\r
73 \r
74 /**\r
75  * Builds this type.\r
76  * @throws {Error} If this type cannot be built directly\r
77  * @expose\r
78  */\r
79 TPrototype.build = function() {\r
80     throw Error(this.toString(true)+" cannot be built directly");\r
81 };\r