1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | var util_1 = require("../util");
|
4 | exports.MESSAGE_TYPE = 11;
|
5 | exports.BYTES_TYPE = 12;
|
6 | exports.ENUM_TYPE = 14;
|
7 | var TypeNumToTypeString = {};
|
8 | TypeNumToTypeString[1] = "number";
|
9 | TypeNumToTypeString[2] = "number";
|
10 | TypeNumToTypeString[3] = "number";
|
11 | TypeNumToTypeString[4] = "number";
|
12 | TypeNumToTypeString[5] = "number";
|
13 | TypeNumToTypeString[6] = "number";
|
14 | TypeNumToTypeString[7] = "number";
|
15 | TypeNumToTypeString[8] = "boolean";
|
16 | TypeNumToTypeString[9] = "string";
|
17 | TypeNumToTypeString[10] = "Object";
|
18 | TypeNumToTypeString[exports.MESSAGE_TYPE] = "Object";
|
19 | TypeNumToTypeString[exports.BYTES_TYPE] = "Uint8Array";
|
20 | TypeNumToTypeString[13] = "number";
|
21 | TypeNumToTypeString[exports.ENUM_TYPE] = "number";
|
22 | TypeNumToTypeString[15] = "number";
|
23 | TypeNumToTypeString[16] = "number";
|
24 | TypeNumToTypeString[17] = "number";
|
25 | TypeNumToTypeString[18] = "number";
|
26 | function getTypeName(fieldTypeNum) {
|
27 | return TypeNumToTypeString[fieldTypeNum];
|
28 | }
|
29 | exports.getTypeName = getTypeName;
|
30 | function getFieldType(type, typeName, currentFileName, exportMap) {
|
31 | if (type === exports.MESSAGE_TYPE) {
|
32 | if (!typeName)
|
33 | return util_1.throwError("Type was Message, but typeName is not set");
|
34 | var fromExport = exportMap.getMessage(typeName);
|
35 | if (!fromExport) {
|
36 | return util_1.throwError("Could not getFieldType for message: " + typeName);
|
37 | }
|
38 | var withinNamespace = util_1.withinNamespaceFromExportEntry(typeName, fromExport);
|
39 | if (fromExport.fileName === currentFileName) {
|
40 | return withinNamespace;
|
41 | }
|
42 | else {
|
43 | return util_1.filePathToPseudoNamespace(fromExport.fileName) + "." + withinNamespace;
|
44 | }
|
45 | }
|
46 | else if (type === exports.ENUM_TYPE) {
|
47 | if (!typeName)
|
48 | return util_1.throwError("Type was Enum, but typeName is not set");
|
49 | var fromExport = exportMap.getEnum(typeName);
|
50 | if (!fromExport) {
|
51 | return util_1.throwError("Could not getFieldType for enum: " + typeName);
|
52 | }
|
53 | var withinNamespace = util_1.withinNamespaceFromExportEntry(typeName, fromExport);
|
54 | if (fromExport.fileName === currentFileName) {
|
55 | return withinNamespace + "Map";
|
56 | }
|
57 | else {
|
58 | return util_1.filePathToPseudoNamespace(fromExport.fileName) + "." + withinNamespace;
|
59 | }
|
60 | }
|
61 | else {
|
62 | return TypeNumToTypeString[type];
|
63 | }
|
64 | }
|
65 | exports.getFieldType = getFieldType;
|
66 |
|
\ | No newline at end of file |