Permalink
Browse files

CLI: $Properties are just a type that's satisfied, not implemented, b…

…y classes, see #723
  • Loading branch information...
dcodeIO committed Mar 26, 2017
1 parent fff1eb2 commit 8de21e1a947ddb50a167147dd63ad29d37b6a891
@@ -299,7 +299,7 @@ function buildType(ref, type) {
var typeDef = [
"Properties of " + aOrAn(type.name) + ".",
"@typedef " + fullName + "$Properties",
"@type Object"
"@type {Object}"
];
type.fieldsArray.forEach(function(field) {
var jsType = toJsType(field),
@@ -317,7 +317,6 @@ function buildType(ref, type) {
"Constructs a new " + type.name + ".",
type.comment ? "@classdesc " + type.comment : null,
"@exports " + fullName,
"@implements " + fullName + "$Properties",
"@constructor",
"@param {" + fullName + "$Properties=} [" + (config.beautify ? "properties" : "p") + "] Properties to set"
]);
@@ -331,6 +330,7 @@ function buildType(ref, type) {
if (config.comments) {
push("");
pushComment([
field.comment || type.name + " " + field.name + ".",
"@type {" + toJsType(field) + (field.optional ? "|undefined" : "") + "}"
]);
} else if (firstField) {
@@ -848,7 +848,7 @@ export class Method extends ReflectionObject {
/**
* Converts this method to a method descriptor.
* @returns {MethodDescriptor}
* @returns {MethodDescriptor} Method descriptor
*/
public toJSON(): MethodDescriptor;
}
@@ -2384,6 +2384,14 @@ export namespace util {
*/
function isObject(value: any): boolean;
/**
* Checks if a property on a message is considered to be present.
* @param {Object} obj Plain object or message instance
* @param {string} prop Property name
* @returns {boolean} `true` if considered to be present, otherwise `false`
*/
function isset(obj: Object, prop: string): boolean;
/**
* Node's Buffer class if available.
* @type {?function(new: Buffer)}
@@ -304,16 +304,19 @@ function writeInterface(element) {
function writeInterfaceBody(element) {
writeln("{");
++indent;
element.properties.forEach(function(property) {
write(property.name);
if (property.optional)
write("?");
writeln(": ", getTypeOf(property), ";");
});
element.properties.forEach(writeProperty);
--indent;
write("}");
}
function writeProperty(property) {
writeComment(property.comment);
write(property.name);
if (property.optional)
write("?");
writeln(": ", getTypeOf(property), ";");
}
//
// Handlers
//
@@ -418,9 +421,13 @@ function handleClass(element, parent) {
++indent;
// constructor
if (!is_interface && !element.virtual)
if (!is_interface && !element.virtual)
handleFunction(element, parent, true);
// properties
if (is_interface && element.properties)
element.properties.forEach(writeProperty);
// class-compatible members
var incompatible = [];
getChildrenOf(element).forEach(function(child) {
@@ -14,7 +14,7 @@ $root.Test1 = (function() {
/**
* Properties of a Test1.
* @typedef Test1$Properties
* @type Object
* @type {Object}
* @property {string} [field1] Field with a comment.
* @property {number} [field2] Test1 field2.
* @property {boolean} [field3] Field with a comment and a <a href="http://example.com/foo/">link</a>
@@ -27,7 +27,6 @@ $root.Test1 = (function() {
* a
* comment.
* @exports Test1
* @implements Test1$Properties
* @constructor
* @param {Test1$Properties=} [properties] Properties to set
*/
@@ -38,16 +37,19 @@ $root.Test1 = (function() {
}
/**
* Field with a comment.
* @type {string|undefined}
*/
Test1.prototype.field1 = "";
/**
* Test1 field2.
* @type {number|undefined}
*/
Test1.prototype.field2 = 0;
/**
* Field with a comment and a <a href="http://example.com/foo/">link</a>
* @type {boolean|undefined}
*/
Test1.prototype.field3 = false;
@@ -230,13 +232,12 @@ $root.Test2 = (function() {
/**
* Properties of a Test2.
* @typedef Test2$Properties
* @type Object
* @type {Object}
*/
/**
* Constructs a new Test2.
* @exports Test2
* @implements Test2$Properties
* @constructor
* @param {Test2$Properties=} [properties] Properties to set
*/
@@ -14,7 +14,7 @@ $root.Message = (function() {
/**
* Properties of a Message.
* @typedef Message$Properties
* @type Object
* @type {Object}
* @property {string} [stringVal] Message stringVal.
* @property {Array.<string>} [stringRepeated] Message stringRepeated.
* @property {number|Long} [uint64Val] Message uint64Val.
@@ -29,7 +29,6 @@ $root.Message = (function() {
/**
* Constructs a new Message.
* @exports Message
* @implements Message$Properties
* @constructor
* @param {Message$Properties=} [properties] Properties to set
*/
@@ -45,46 +44,55 @@ $root.Message = (function() {
}
/**
* Message stringVal.
* @type {string|undefined}
*/
Message.prototype.stringVal = "";
/**
* Message stringRepeated.
* @type {Array.<string>|undefined}
*/
Message.prototype.stringRepeated = $util.emptyArray;
/**
* Message uint64Val.
* @type {number|Long|undefined}
*/
Message.prototype.uint64Val = $util.Long ? $util.Long.fromBits(0,0,true) : 0;
/**
* Message uint64Repeated.
* @type {Array.<number|Long>|undefined}
*/
Message.prototype.uint64Repeated = $util.emptyArray;
/**
* Message bytesVal.
* @type {Uint8Array|undefined}
*/
Message.prototype.bytesVal = $util.newBuffer([]);
/**
* Message bytesRepeated.
* @type {Array.<Uint8Array>|undefined}
*/
Message.prototype.bytesRepeated = $util.emptyArray;
/**
* Message enumVal.
* @type {Message.SomeEnum|undefined}
*/
Message.prototype.enumVal = 1;
/**
* Message enumRepeated.
* @type {Array.<Message.SomeEnum>|undefined}
*/
Message.prototype.enumRepeated = $util.emptyArray;
/**
* Message int64Map.
* @type {Object.<string,number|Long>|undefined}
*/
Message.prototype.int64Map = $util.emptyObject;
@@ -212,7 +220,7 @@ $root.Message = (function() {
message.int64Map = {};
key = reader.string();
reader.pos++;
message.int64Map[typeof key === "object" ? $util.longToHash(key) : key] = reader.int64();
message.int64Map[key] = reader.int64();
break;
default:
reader.skipType(tag & 7);
Oops, something went wrong.

0 comments on commit 8de21e1

Please sign in to comment.