Further reshuffle Protobufs; generate JavaScript code

After a bit more thinking, we will create new SDK packages for each
of the languages we wish to support writing resource providers in.
This is where the RPC goo will live, so I have created a new sdk/
directory, moved the Protobuf/gRPC definitions underneath sdk/proto/,
and put the generated code into sdk/go/ and sdk/js/.
This commit is contained in:
joeduffy 2017-02-10 09:28:46 -08:00
parent d67de40cf6
commit 11b7880547
10 changed files with 1277 additions and 4 deletions

View file

@ -3,6 +3,8 @@
This directory contains the various MuPackage libraries that Mu programs may depend upon. The Mu standard library
(under `mu/`) is special in that every Mu program will ultimately use it directly or indirectly to create resources.
Note that these are written in the Mu subsets of the languages and therefore cannot perform I/O, etc.
Eventually these packages will be published like any other NPM MuPackage. For now, they are consumed only in a
development capacity, and so there are some manual steps required to prepare a development workspace.

View file

@ -1,2 +0,0 @@
bin/

7
sdk/README.md Normal file
View file

@ -0,0 +1,7 @@
# sdk
The SDK directory contains language packages for the various supported languages.
These packages are real language packages and not MuPackages. Therefore, they can contain I/O, asynchronous code, and
anything else necessary for building runtime code, resource providers, and other helpful Mu tooling and abstractions.

View file

@ -0,0 +1,192 @@
/**
* @fileoverview
* @enhanceable
* @public
*/
// GENERATED CODE -- DO NOT EDIT!
var jspb = require('google-protobuf');
var goog = jspb;
var global = Function('return this')();
var google_protobuf_empty_pb = require('google-protobuf/google/protobuf/empty_pb.js');
goog.exportSymbol('proto.murpc.LogRequest', null, global);
goog.exportSymbol('proto.murpc.LogSeverity', null, global);
/**
* Generated by JsPbCodeGenerator.
* @param {Array=} opt_data Optional initial data array, typically from a
* server response, or constructed directly in Javascript. The array is used
* in place and becomes part of the constructed object. It is not cloned.
* If no data is provided, the constructed object will be empty, but still
* valid.
* @extends {jspb.Message}
* @constructor
*/
proto.murpc.LogRequest = function(opt_data) {
jspb.Message.initialize(this, opt_data, 0, -1, null, null);
};
goog.inherits(proto.murpc.LogRequest, jspb.Message);
if (goog.DEBUG && !COMPILED) {
proto.murpc.LogRequest.displayName = 'proto.murpc.LogRequest';
}
if (jspb.Message.GENERATE_TO_OBJECT) {
/**
* Creates an object representation of this proto suitable for use in Soy templates.
* Field names that are reserved in JavaScript and will be renamed to pb_name.
* To access a reserved field use, foo.pb_<name>, eg, foo.pb_default.
* For the list of reserved names please see:
* com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS.
* @param {boolean=} opt_includeInstance Whether to include the JSPB instance
* for transitional soy proto support: http://goto/soy-param-migration
* @return {!Object}
*/
proto.murpc.LogRequest.prototype.toObject = function(opt_includeInstance) {
return proto.murpc.LogRequest.toObject(opt_includeInstance, this);
};
/**
* Static version of the {@see toObject} method.
* @param {boolean|undefined} includeInstance Whether to include the JSPB
* instance for transitional soy proto support:
* http://goto/soy-param-migration
* @param {!proto.murpc.LogRequest} msg The msg instance to transform.
* @return {!Object}
*/
proto.murpc.LogRequest.toObject = function(includeInstance, msg) {
var f, obj = {
severity: jspb.Message.getFieldWithDefault(msg, 1, 0),
message: jspb.Message.getFieldWithDefault(msg, 2, "")
};
if (includeInstance) {
obj.$jspbMessageInstance = msg;
}
return obj;
};
}
/**
* Deserializes binary data (in protobuf wire format).
* @param {jspb.ByteSource} bytes The bytes to deserialize.
* @return {!proto.murpc.LogRequest}
*/
proto.murpc.LogRequest.deserializeBinary = function(bytes) {
var reader = new jspb.BinaryReader(bytes);
var msg = new proto.murpc.LogRequest;
return proto.murpc.LogRequest.deserializeBinaryFromReader(msg, reader);
};
/**
* Deserializes binary data (in protobuf wire format) from the
* given reader into the given message object.
* @param {!proto.murpc.LogRequest} msg The message object to deserialize into.
* @param {!jspb.BinaryReader} reader The BinaryReader to use.
* @return {!proto.murpc.LogRequest}
*/
proto.murpc.LogRequest.deserializeBinaryFromReader = function(msg, reader) {
while (reader.nextField()) {
if (reader.isEndGroup()) {
break;
}
var field = reader.getFieldNumber();
switch (field) {
case 1:
var value = /** @type {!proto.murpc.LogSeverity} */ (reader.readEnum());
msg.setSeverity(value);
break;
case 2:
var value = /** @type {string} */ (reader.readString());
msg.setMessage(value);
break;
default:
reader.skipField();
break;
}
}
return msg;
};
/**
* Serializes the message to binary data (in protobuf wire format).
* @return {!Uint8Array}
*/
proto.murpc.LogRequest.prototype.serializeBinary = function() {
var writer = new jspb.BinaryWriter();
proto.murpc.LogRequest.serializeBinaryToWriter(this, writer);
return writer.getResultBuffer();
};
/**
* Serializes the given message to binary data (in protobuf wire
* format), writing to the given BinaryWriter.
* @param {!proto.murpc.LogRequest} message
* @param {!jspb.BinaryWriter} writer
*/
proto.murpc.LogRequest.serializeBinaryToWriter = function(message, writer) {
var f = undefined;
f = message.getSeverity();
if (f !== 0.0) {
writer.writeEnum(
1,
f
);
}
f = message.getMessage();
if (f.length > 0) {
writer.writeString(
2,
f
);
}
};
/**
* optional LogSeverity severity = 1;
* @return {!proto.murpc.LogSeverity}
*/
proto.murpc.LogRequest.prototype.getSeverity = function() {
return /** @type {!proto.murpc.LogSeverity} */ (jspb.Message.getFieldWithDefault(this, 1, 0));
};
/** @param {!proto.murpc.LogSeverity} value */
proto.murpc.LogRequest.prototype.setSeverity = function(value) {
jspb.Message.setField(this, 1, value);
};
/**
* optional string message = 2;
* @return {string}
*/
proto.murpc.LogRequest.prototype.getMessage = function() {
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, ""));
};
/** @param {string} value */
proto.murpc.LogRequest.prototype.setMessage = function(value) {
jspb.Message.setField(this, 2, value);
};
/**
* @enum {number}
*/
proto.murpc.LogSeverity = {
DEBUG: 0,
INFO: 1,
WARNING: 2,
ERROR: 3
};
goog.object.extend(exports, proto.murpc);

File diff suppressed because it is too large Load diff

View file

@ -14,6 +14,17 @@
# The results are checked into bin/; at this moment, they need to be copied to their final destinations manually.
set -e
mkdir -p bin/
protoc --go_out=plugins=grpc:bin/ *.proto
GO_MURPC=../go/murpc
GO_PROTOFLAGS="plugins=grpc"
JS_MURPC=../js/src/murpc
JS_PROTOFLAGS="import_style=commonjs,binary"
echo Generating Protobuf/gRPC SDK files:
echo \\tGo: $GO_MURPC [$GO_PROTOFLAGS]
echo \\tJS: $JS_MURPC [$JS_PROTOFLAGS]
mkdir -p $GO_MURPC $JS_MURPC
protoc --go_out=$GO_PROTOFLAGS:$GO_MURPC --js_out=$JS_PROTOFLAGS:$JS_MURPC *.proto
echo Done.