Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: output-encode-only methods #787

Merged
merged 7 commits into from
Mar 8, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added integration/output-decode-only/encode.bin
Binary file not shown.
8 changes: 8 additions & 0 deletions integration/output-decode-only/encode.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
syntax = "proto3";

import "google/protobuf/wrappers.proto";

message Encode {
string encode = 1;
}

32 changes: 32 additions & 0 deletions integration/output-decode-only/encode.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/* eslint-disable */
import * as _m0 from "protobufjs/minimal";

export const protobufPackage = "";

export interface Encode {
encode: string;
}

function createBaseEncode(): Encode {
return { encode: "" };
}

export const Encode = {
decode(input: _m0.Reader | Uint8Array, length?: number): Encode {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseEncode();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
message.encode = reader.string();
break;
default:
reader.skipType(tag & 7);
break;
}
}
return message;
},
};
344 changes: 344 additions & 0 deletions integration/output-decode-only/google/protobuf/wrappers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,344 @@
/* eslint-disable */
import * as Long from "long";
import * as _m0 from "protobufjs/minimal";

export const protobufPackage = "google.protobuf";

/**
* Wrapper message for `double`.
*
* The JSON representation for `DoubleValue` is JSON number.
*/
export interface DoubleValue {
/** The double value. */
value: number;
}

/**
* Wrapper message for `float`.
*
* The JSON representation for `FloatValue` is JSON number.
*/
export interface FloatValue {
/** The float value. */
value: number;
}

/**
* Wrapper message for `int64`.
*
* The JSON representation for `Int64Value` is JSON string.
*/
export interface Int64Value {
/** The int64 value. */
value: number;
}

/**
* Wrapper message for `uint64`.
*
* The JSON representation for `UInt64Value` is JSON string.
*/
export interface UInt64Value {
/** The uint64 value. */
value: number;
}

/**
* Wrapper message for `int32`.
*
* The JSON representation for `Int32Value` is JSON number.
*/
export interface Int32Value {
/** The int32 value. */
value: number;
}

/**
* Wrapper message for `uint32`.
*
* The JSON representation for `UInt32Value` is JSON number.
*/
export interface UInt32Value {
/** The uint32 value. */
value: number;
}

/**
* Wrapper message for `bool`.
*
* The JSON representation for `BoolValue` is JSON `true` and `false`.
*/
export interface BoolValue {
/** The bool value. */
value: boolean;
}

/**
* Wrapper message for `string`.
*
* The JSON representation for `StringValue` is JSON string.
*/
export interface StringValue {
/** The string value. */
value: string;
}

/**
* Wrapper message for `bytes`.
*
* The JSON representation for `BytesValue` is JSON string.
*/
export interface BytesValue {
/** The bytes value. */
value: Uint8Array;
}

function createBaseDoubleValue(): DoubleValue {
return { value: 0 };
}

export const DoubleValue = {
decode(input: _m0.Reader | Uint8Array, length?: number): DoubleValue {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseDoubleValue();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
message.value = reader.double();
break;
default:
reader.skipType(tag & 7);
break;
}
}
return message;
},
};

function createBaseFloatValue(): FloatValue {
return { value: 0 };
}

export const FloatValue = {
decode(input: _m0.Reader | Uint8Array, length?: number): FloatValue {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseFloatValue();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
message.value = reader.float();
break;
default:
reader.skipType(tag & 7);
break;
}
}
return message;
},
};

function createBaseInt64Value(): Int64Value {
return { value: 0 };
}

export const Int64Value = {
decode(input: _m0.Reader | Uint8Array, length?: number): Int64Value {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseInt64Value();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
message.value = longToNumber(reader.int64() as Long);
break;
default:
reader.skipType(tag & 7);
break;
}
}
return message;
},
};

function createBaseUInt64Value(): UInt64Value {
return { value: 0 };
}

export const UInt64Value = {
decode(input: _m0.Reader | Uint8Array, length?: number): UInt64Value {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseUInt64Value();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
message.value = longToNumber(reader.uint64() as Long);
break;
default:
reader.skipType(tag & 7);
break;
}
}
return message;
},
};

function createBaseInt32Value(): Int32Value {
return { value: 0 };
}

export const Int32Value = {
decode(input: _m0.Reader | Uint8Array, length?: number): Int32Value {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseInt32Value();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
message.value = reader.int32();
break;
default:
reader.skipType(tag & 7);
break;
}
}
return message;
},
};

function createBaseUInt32Value(): UInt32Value {
return { value: 0 };
}

export const UInt32Value = {
decode(input: _m0.Reader | Uint8Array, length?: number): UInt32Value {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseUInt32Value();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
message.value = reader.uint32();
break;
default:
reader.skipType(tag & 7);
break;
}
}
return message;
},
};

function createBaseBoolValue(): BoolValue {
return { value: false };
}

export const BoolValue = {
decode(input: _m0.Reader | Uint8Array, length?: number): BoolValue {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseBoolValue();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
message.value = reader.bool();
break;
default:
reader.skipType(tag & 7);
break;
}
}
return message;
},
};

function createBaseStringValue(): StringValue {
return { value: "" };
}

export const StringValue = {
decode(input: _m0.Reader | Uint8Array, length?: number): StringValue {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseStringValue();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
message.value = reader.string();
break;
default:
reader.skipType(tag & 7);
break;
}
}
return message;
},
};

function createBaseBytesValue(): BytesValue {
return { value: new Uint8Array() };
}

export const BytesValue = {
decode(input: _m0.Reader | Uint8Array, length?: number): BytesValue {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseBytesValue();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
message.value = reader.bytes();
break;
default:
reader.skipType(tag & 7);
break;
}
}
return message;
},
};

declare var self: any | undefined;
declare var window: any | undefined;
declare var global: any | undefined;
var tsProtoGlobalThis: any = (() => {
if (typeof globalThis !== "undefined") {
return globalThis;
}
if (typeof self !== "undefined") {
return self;
}
if (typeof window !== "undefined") {
return window;
}
if (typeof global !== "undefined") {
return global;
}
throw "Unable to locate global object";
})();

function longToNumber(long: Long): number {
if (long.gt(Number.MAX_SAFE_INTEGER)) {
throw new tsProtoGlobalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER");
}
return long.toNumber();
}

// If you get a compile-error about 'Constructor<Long> and ... have no overlap',
// add '--ts_proto_opt=esModuleInterop=true' as a flag when calling 'protoc'.
if (_m0.util.Long !== Long) {
_m0.util.Long = Long as any;
_m0.configure();
}
1 change: 1 addition & 0 deletions integration/output-decode-only/parameters.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
outputEncodeMethods=decode-only,outputPartialMethods=false,outputJsonMethods=false
Binary file not shown.
8 changes: 8 additions & 0 deletions integration/output-encode-no-creation-methods/encode.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
syntax = "proto3";

import "google/protobuf/wrappers.proto";

message Encode {
string encode = 1;
}

Loading