From 5dba5b3f2c453111f8028473c3aff3a956b287fe Mon Sep 17 00:00:00 2001 From: ImUrX Date: Thu, 3 Aug 2023 02:23:57 -0300 Subject: [PATCH 1/5] change how save file actually works --- .../generated/all_generated.h | 78 ++++++++++--- .../rpc/SaveFileNotification.java | 60 +++------- .../rpc/SaveFileNotificationT.java | 6 - .../rpc/SaveFileResponse.java | 62 ++++++++++ .../rpc/SaveFileResponseT.java | 22 ++++ .../rpc/SaveFileNotification.kt | 64 +++------- .../solarxr_protocol/rpc/SaveFileResponse.kt | 55 +++++++++ protocol/rust/src/generated/mod.rs | 2 + .../rpc/save_file_notification_generated.rs | 26 +---- .../rpc/save_file_response_generated.rs | 109 ++++++++++++++++++ protocol/typescript/src/all_generated.ts | 1 + .../rpc/save-file-notification.ts | 60 ++-------- .../rpc/save-file-response.ts | 79 +++++++++++++ schema/rpc.fbs | 7 +- 14 files changed, 442 insertions(+), 189 deletions(-) create mode 100644 protocol/java/src/solarxr_protocol/rpc/SaveFileResponse.java create mode 100644 protocol/java/src/solarxr_protocol/rpc/SaveFileResponseT.java create mode 100644 protocol/kotlin/src/solarxr_protocol/rpc/SaveFileResponse.kt create mode 100644 protocol/rust/src/generated/solarxr_protocol/rpc/save_file_response_generated.rs create mode 100644 protocol/typescript/src/solarxr-protocol/rpc/save-file-response.ts diff --git a/protocol/cpp/include/solarxr_protocol/generated/all_generated.h b/protocol/cpp/include/solarxr_protocol/generated/all_generated.h index 86e1aa9f..e1caa6df 100644 --- a/protocol/cpp/include/solarxr_protocol/generated/all_generated.h +++ b/protocol/cpp/include/solarxr_protocol/generated/all_generated.h @@ -327,6 +327,9 @@ struct ClearMountingResetRequestBuilder; struct SaveFileNotification; struct SaveFileNotificationBuilder; +struct SaveFileResponse; +struct SaveFileResponseBuilder; + } // namespace rpc namespace pub_sub { @@ -8171,16 +8174,11 @@ inline flatbuffers::Offset CreateClearMountingResetRe struct SaveFileNotification FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef SaveFileNotificationBuilder Builder; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_DATA = 4, - VT_MIME_TYPE = 6, - VT_FILE_EXTENSION = 8, - VT_EXPECTED_DIR = 10, - VT_EXPECTED_FILENAME = 12 + VT_MIME_TYPE = 4, + VT_FILE_EXTENSION = 6, + VT_EXPECTED_DIR = 8, + VT_EXPECTED_FILENAME = 10 }; - /// Binary data of the file - const flatbuffers::Vector *data() const { - return GetPointer *>(VT_DATA); - } /// MIME type of file if one exists, use `file_extension` otherwise const flatbuffers::String *mime_type() const { return GetPointer(VT_MIME_TYPE); @@ -8199,8 +8197,6 @@ struct SaveFileNotification FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && - VerifyOffset(verifier, VT_DATA) && - verifier.VerifyVector(data()) && VerifyOffset(verifier, VT_MIME_TYPE) && verifier.VerifyString(mime_type()) && VerifyOffset(verifier, VT_FILE_EXTENSION) && @@ -8216,9 +8212,6 @@ struct SaveFileNotificationBuilder { typedef SaveFileNotification Table; flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; - void add_data(flatbuffers::Offset> data) { - fbb_.AddOffset(SaveFileNotification::VT_DATA, data); - } void add_mime_type(flatbuffers::Offset mime_type) { fbb_.AddOffset(SaveFileNotification::VT_MIME_TYPE, mime_type); } @@ -8244,7 +8237,6 @@ struct SaveFileNotificationBuilder { inline flatbuffers::Offset CreateSaveFileNotification( flatbuffers::FlatBufferBuilder &_fbb, - flatbuffers::Offset> data = 0, flatbuffers::Offset mime_type = 0, flatbuffers::Offset file_extension = 0, flatbuffers::Optional expected_dir = flatbuffers::nullopt, @@ -8253,31 +8245,79 @@ inline flatbuffers::Offset CreateSaveFileNotification( builder_.add_expected_filename(expected_filename); builder_.add_file_extension(file_extension); builder_.add_mime_type(mime_type); - builder_.add_data(data); if(expected_dir) { builder_.add_expected_dir(*expected_dir); } return builder_.Finish(); } inline flatbuffers::Offset CreateSaveFileNotificationDirect( flatbuffers::FlatBufferBuilder &_fbb, - const std::vector *data = nullptr, const char *mime_type = nullptr, const char *file_extension = nullptr, flatbuffers::Optional expected_dir = flatbuffers::nullopt, const char *expected_filename = nullptr) { - auto data__ = data ? _fbb.CreateVector(*data) : 0; auto mime_type__ = mime_type ? _fbb.CreateString(mime_type) : 0; auto file_extension__ = file_extension ? _fbb.CreateString(file_extension) : 0; auto expected_filename__ = expected_filename ? _fbb.CreateString(expected_filename) : 0; return solarxr_protocol::rpc::CreateSaveFileNotification( _fbb, - data__, mime_type__, file_extension__, expected_dir, expected_filename__); } +struct SaveFileResponse FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { + typedef SaveFileResponseBuilder Builder; + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_PATH = 4 + }; + /// Where to save the file, if null, server will choose where to save it + const flatbuffers::String *path() const { + return GetPointer(VT_PATH); + } + bool Verify(flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyOffset(verifier, VT_PATH) && + verifier.VerifyString(path()) && + verifier.EndTable(); + } +}; + +struct SaveFileResponseBuilder { + typedef SaveFileResponse Table; + flatbuffers::FlatBufferBuilder &fbb_; + flatbuffers::uoffset_t start_; + void add_path(flatbuffers::Offset path) { + fbb_.AddOffset(SaveFileResponse::VT_PATH, path); + } + explicit SaveFileResponseBuilder(flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = flatbuffers::Offset(end); + return o; + } +}; + +inline flatbuffers::Offset CreateSaveFileResponse( + flatbuffers::FlatBufferBuilder &_fbb, + flatbuffers::Offset path = 0) { + SaveFileResponseBuilder builder_(_fbb); + builder_.add_path(path); + return builder_.Finish(); +} + +inline flatbuffers::Offset CreateSaveFileResponseDirect( + flatbuffers::FlatBufferBuilder &_fbb, + const char *path = nullptr) { + auto path__ = path ? _fbb.CreateString(path) : 0; + return solarxr_protocol::rpc::CreateSaveFileResponse( + _fbb, + path__); +} + } // namespace rpc namespace pub_sub { diff --git a/protocol/java/src/solarxr_protocol/rpc/SaveFileNotification.java b/protocol/java/src/solarxr_protocol/rpc/SaveFileNotification.java index 09806c28..4a4c7774 100644 --- a/protocol/java/src/solarxr_protocol/rpc/SaveFileNotification.java +++ b/protocol/java/src/solarxr_protocol/rpc/SaveFileNotification.java @@ -18,63 +18,48 @@ public final class SaveFileNotification extends Table { public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); } public SaveFileNotification __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; } - /** - * Binary data of the file - */ - public int data(int j) { int o = __offset(4); return o != 0 ? bb.get(__vector(o) + j * 1) & 0xFF : 0; } - public int dataLength() { int o = __offset(4); return o != 0 ? __vector_len(o) : 0; } - public ByteVector dataVector() { return dataVector(new ByteVector()); } - public ByteVector dataVector(ByteVector obj) { int o = __offset(4); return o != 0 ? obj.__assign(__vector(o), bb) : null; } - public ByteBuffer dataAsByteBuffer() { return __vector_as_bytebuffer(4, 1); } - public ByteBuffer dataInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 4, 1); } /** * MIME type of file if one exists, use `file_extension` otherwise */ - public String mimeType() { int o = __offset(6); return o != 0 ? __string(o + bb_pos) : null; } - public ByteBuffer mimeTypeAsByteBuffer() { return __vector_as_bytebuffer(6, 1); } - public ByteBuffer mimeTypeInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 6, 1); } + public String mimeType() { int o = __offset(4); return o != 0 ? __string(o + bb_pos) : null; } + public ByteBuffer mimeTypeAsByteBuffer() { return __vector_as_bytebuffer(4, 1); } + public ByteBuffer mimeTypeInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 4, 1); } /** * Use MIME type preferably if one exists */ - public String fileExtension() { int o = __offset(8); return o != 0 ? __string(o + bb_pos) : null; } - public ByteBuffer fileExtensionAsByteBuffer() { return __vector_as_bytebuffer(8, 1); } - public ByteBuffer fileExtensionInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 8, 1); } + public String fileExtension() { int o = __offset(6); return o != 0 ? __string(o + bb_pos) : null; } + public ByteBuffer fileExtensionAsByteBuffer() { return __vector_as_bytebuffer(6, 1); } + public ByteBuffer fileExtensionInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 6, 1); } /** * Directory recommended to save the file on */ - public boolean hasExpectedDir() { return 0 != __offset(10); } - public int expectedDir() { int o = __offset(10); return o != 0 ? bb.get(o + bb_pos) & 0xFF : 0; } + public boolean hasExpectedDir() { return 0 != __offset(8); } + public int expectedDir() { int o = __offset(8); return o != 0 ? bb.get(o + bb_pos) & 0xFF : 0; } /** * Recommended filename */ - public String expectedFilename() { int o = __offset(12); return o != 0 ? __string(o + bb_pos) : null; } - public ByteBuffer expectedFilenameAsByteBuffer() { return __vector_as_bytebuffer(12, 1); } - public ByteBuffer expectedFilenameInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 12, 1); } + public String expectedFilename() { int o = __offset(10); return o != 0 ? __string(o + bb_pos) : null; } + public ByteBuffer expectedFilenameAsByteBuffer() { return __vector_as_bytebuffer(10, 1); } + public ByteBuffer expectedFilenameInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 10, 1); } public static int createSaveFileNotification(FlatBufferBuilder builder, - int dataOffset, int mimeTypeOffset, int fileExtensionOffset, int expectedDir, int expectedFilenameOffset) { - builder.startTable(5); + builder.startTable(4); SaveFileNotification.addExpectedFilename(builder, expectedFilenameOffset); SaveFileNotification.addFileExtension(builder, fileExtensionOffset); SaveFileNotification.addMimeType(builder, mimeTypeOffset); - SaveFileNotification.addData(builder, dataOffset); SaveFileNotification.addExpectedDir(builder, expectedDir); return SaveFileNotification.endSaveFileNotification(builder); } - public static void startSaveFileNotification(FlatBufferBuilder builder) { builder.startTable(5); } - public static void addData(FlatBufferBuilder builder, int dataOffset) { builder.addOffset(0, dataOffset, 0); } - public static int createDataVector(FlatBufferBuilder builder, byte[] data) { return builder.createByteVector(data); } - public static int createDataVector(FlatBufferBuilder builder, ByteBuffer data) { return builder.createByteVector(data); } - public static void startDataVector(FlatBufferBuilder builder, int numElems) { builder.startVector(1, numElems, 1); } - public static void addMimeType(FlatBufferBuilder builder, int mimeTypeOffset) { builder.addOffset(1, mimeTypeOffset, 0); } - public static void addFileExtension(FlatBufferBuilder builder, int fileExtensionOffset) { builder.addOffset(2, fileExtensionOffset, 0); } - public static void addExpectedDir(FlatBufferBuilder builder, int expectedDir) { builder.addByte(3, (byte) expectedDir, (byte) 0); } - public static void addExpectedFilename(FlatBufferBuilder builder, int expectedFilenameOffset) { builder.addOffset(4, expectedFilenameOffset, 0); } + public static void startSaveFileNotification(FlatBufferBuilder builder) { builder.startTable(4); } + public static void addMimeType(FlatBufferBuilder builder, int mimeTypeOffset) { builder.addOffset(0, mimeTypeOffset, 0); } + public static void addFileExtension(FlatBufferBuilder builder, int fileExtensionOffset) { builder.addOffset(1, fileExtensionOffset, 0); } + public static void addExpectedDir(FlatBufferBuilder builder, int expectedDir) { builder.addByte(2, (byte) expectedDir, (byte) 0); } + public static void addExpectedFilename(FlatBufferBuilder builder, int expectedFilenameOffset) { builder.addOffset(3, expectedFilenameOffset, 0); } public static int endSaveFileNotification(FlatBufferBuilder builder) { int o = builder.endTable(); return o; @@ -92,9 +77,6 @@ public SaveFileNotificationT unpack() { return _o; } public void unpackTo(SaveFileNotificationT _o) { - int[] _oData = new int[dataLength()]; - for (int _j = 0; _j < dataLength(); ++_j) {_oData[_j] = data(_j);} - _o.setData(_oData); String _oMimeType = mimeType(); _o.setMimeType(_oMimeType); String _oFileExtension = fileExtension(); @@ -106,19 +88,11 @@ public void unpackTo(SaveFileNotificationT _o) { } public static int pack(FlatBufferBuilder builder, SaveFileNotificationT _o) { if (_o == null) return 0; - int _data = 0; - if (_o.getData() != null) { - byte[] __data = new byte[_o.getData().length]; - int _j = 0; - for (int _e : _o.getData()) { __data[_j] = (byte) _e; _j++;} - _data = createDataVector(builder, __data); - } int _mimeType = _o.getMimeType() == null ? 0 : builder.createString(_o.getMimeType()); int _fileExtension = _o.getFileExtension() == null ? 0 : builder.createString(_o.getFileExtension()); int _expectedFilename = _o.getExpectedFilename() == null ? 0 : builder.createString(_o.getExpectedFilename()); return createSaveFileNotification( builder, - _data, _mimeType, _fileExtension, _o.getExpectedDir(), diff --git a/protocol/java/src/solarxr_protocol/rpc/SaveFileNotificationT.java b/protocol/java/src/solarxr_protocol/rpc/SaveFileNotificationT.java index a517e544..af2d75b8 100644 --- a/protocol/java/src/solarxr_protocol/rpc/SaveFileNotificationT.java +++ b/protocol/java/src/solarxr_protocol/rpc/SaveFileNotificationT.java @@ -8,16 +8,11 @@ import com.google.flatbuffers.*; public class SaveFileNotificationT { - private int[] data; private String mimeType; private String fileExtension; private Integer expectedDir; private String expectedFilename; - public int[] getData() { return data; } - - public void setData(int[] data) { this.data = data; } - public String getMimeType() { return mimeType; } public void setMimeType(String mimeType) { this.mimeType = mimeType; } @@ -36,7 +31,6 @@ public class SaveFileNotificationT { public SaveFileNotificationT() { - this.data = null; this.mimeType = null; this.fileExtension = null; this.expectedDir = null; diff --git a/protocol/java/src/solarxr_protocol/rpc/SaveFileResponse.java b/protocol/java/src/solarxr_protocol/rpc/SaveFileResponse.java new file mode 100644 index 00000000..05d72f31 --- /dev/null +++ b/protocol/java/src/solarxr_protocol/rpc/SaveFileResponse.java @@ -0,0 +1,62 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +package solarxr_protocol.rpc; + +import java.nio.*; +import java.lang.*; +import java.util.*; +import com.google.flatbuffers.*; + +@SuppressWarnings("unused") +public final class SaveFileResponse extends Table { + public static void ValidateVersion() { Constants.FLATBUFFERS_22_10_26(); } + public static SaveFileResponse getRootAsSaveFileResponse(ByteBuffer _bb) { return getRootAsSaveFileResponse(_bb, new SaveFileResponse()); } + public static SaveFileResponse getRootAsSaveFileResponse(ByteBuffer _bb, SaveFileResponse obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); } + public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); } + public SaveFileResponse __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; } + + /** + * Where to save the file, if null, server will choose where to save it + */ + public String path() { int o = __offset(4); return o != 0 ? __string(o + bb_pos) : null; } + public ByteBuffer pathAsByteBuffer() { return __vector_as_bytebuffer(4, 1); } + public ByteBuffer pathInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 4, 1); } + + public static int createSaveFileResponse(FlatBufferBuilder builder, + int pathOffset) { + builder.startTable(1); + SaveFileResponse.addPath(builder, pathOffset); + return SaveFileResponse.endSaveFileResponse(builder); + } + + public static void startSaveFileResponse(FlatBufferBuilder builder) { builder.startTable(1); } + public static void addPath(FlatBufferBuilder builder, int pathOffset) { builder.addOffset(0, pathOffset, 0); } + public static int endSaveFileResponse(FlatBufferBuilder builder) { + int o = builder.endTable(); + return o; + } + + public static final class Vector extends BaseVector { + public Vector __assign(int _vector, int _element_size, ByteBuffer _bb) { __reset(_vector, _element_size, _bb); return this; } + + public SaveFileResponse get(int j) { return get(new SaveFileResponse(), j); } + public SaveFileResponse get(SaveFileResponse obj, int j) { return obj.__assign(__indirect(__element(j), bb), bb); } + } + public SaveFileResponseT unpack() { + SaveFileResponseT _o = new SaveFileResponseT(); + unpackTo(_o); + return _o; + } + public void unpackTo(SaveFileResponseT _o) { + String _oPath = path(); + _o.setPath(_oPath); + } + public static int pack(FlatBufferBuilder builder, SaveFileResponseT _o) { + if (_o == null) return 0; + int _path = _o.getPath() == null ? 0 : builder.createString(_o.getPath()); + return createSaveFileResponse( + builder, + _path); + } +} + diff --git a/protocol/java/src/solarxr_protocol/rpc/SaveFileResponseT.java b/protocol/java/src/solarxr_protocol/rpc/SaveFileResponseT.java new file mode 100644 index 00000000..7cfc1616 --- /dev/null +++ b/protocol/java/src/solarxr_protocol/rpc/SaveFileResponseT.java @@ -0,0 +1,22 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +package solarxr_protocol.rpc; + +import java.nio.*; +import java.lang.*; +import java.util.*; +import com.google.flatbuffers.*; + +public class SaveFileResponseT { + private String path; + + public String getPath() { return path; } + + public void setPath(String path) { this.path = path; } + + + public SaveFileResponseT() { + this.path = null; + } +} + diff --git a/protocol/kotlin/src/solarxr_protocol/rpc/SaveFileNotification.kt b/protocol/kotlin/src/solarxr_protocol/rpc/SaveFileNotification.kt index da35d2a7..ab49439b 100644 --- a/protocol/kotlin/src/solarxr_protocol/rpc/SaveFileNotification.kt +++ b/protocol/kotlin/src/solarxr_protocol/rpc/SaveFileNotification.kt @@ -19,49 +19,32 @@ class SaveFileNotification : Table() { __init(_i, _bb) return this } - /** - * Binary data of the file - */ - fun data(j: Int) : UByte { - val o = __offset(4) - return if (o != 0) { - bb.get(__vector(o) + j * 1).toUByte() - } else { - 0u - } - } - val dataLength : Int - get() { - val o = __offset(4); return if (o != 0) __vector_len(o) else 0 - } - val dataAsByteBuffer : ByteBuffer get() = __vector_as_bytebuffer(4, 1) - fun dataInByteBuffer(_bb: ByteBuffer) : ByteBuffer = __vector_in_bytebuffer(_bb, 4, 1) /** * MIME type of file if one exists, use `file_extension` otherwise */ val mimeType : String? get() { - val o = __offset(6) + val o = __offset(4) return if (o != 0) __string(o + bb_pos) else null } - val mimeTypeAsByteBuffer : ByteBuffer get() = __vector_as_bytebuffer(6, 1) - fun mimeTypeInByteBuffer(_bb: ByteBuffer) : ByteBuffer = __vector_in_bytebuffer(_bb, 6, 1) + val mimeTypeAsByteBuffer : ByteBuffer get() = __vector_as_bytebuffer(4, 1) + fun mimeTypeInByteBuffer(_bb: ByteBuffer) : ByteBuffer = __vector_in_bytebuffer(_bb, 4, 1) /** * Use MIME type preferably if one exists */ val fileExtension : String? get() { - val o = __offset(8) + val o = __offset(6) return if (o != 0) __string(o + bb_pos) else null } - val fileExtensionAsByteBuffer : ByteBuffer get() = __vector_as_bytebuffer(8, 1) - fun fileExtensionInByteBuffer(_bb: ByteBuffer) : ByteBuffer = __vector_in_bytebuffer(_bb, 8, 1) + val fileExtensionAsByteBuffer : ByteBuffer get() = __vector_as_bytebuffer(6, 1) + fun fileExtensionInByteBuffer(_bb: ByteBuffer) : ByteBuffer = __vector_in_bytebuffer(_bb, 6, 1) /** * Directory recommended to save the file on */ val expectedDir : UByte? get() { - val o = __offset(10) + val o = __offset(8) return if(o != 0) bb.get(o + bb_pos).toUByte() else null } /** @@ -69,11 +52,11 @@ class SaveFileNotification : Table() { */ val expectedFilename : String? get() { - val o = __offset(12) + val o = __offset(10) return if (o != 0) __string(o + bb_pos) else null } - val expectedFilenameAsByteBuffer : ByteBuffer get() = __vector_as_bytebuffer(12, 1) - fun expectedFilenameInByteBuffer(_bb: ByteBuffer) : ByteBuffer = __vector_in_bytebuffer(_bb, 12, 1) + val expectedFilenameAsByteBuffer : ByteBuffer get() = __vector_as_bytebuffer(10, 1) + fun expectedFilenameInByteBuffer(_bb: ByteBuffer) : ByteBuffer = __vector_in_bytebuffer(_bb, 10, 1) companion object { @JvmStatic fun validateVersion() = Constants.FLATBUFFERS_22_10_26() @@ -85,37 +68,24 @@ class SaveFileNotification : Table() { return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)) } @JvmStatic - fun createSaveFileNotification(builder: FlatBufferBuilder, dataOffset: Int, mimeTypeOffset: Int, fileExtensionOffset: Int, expectedDir: UByte?, expectedFilenameOffset: Int) : Int { - builder.startTable(5) + fun createSaveFileNotification(builder: FlatBufferBuilder, mimeTypeOffset: Int, fileExtensionOffset: Int, expectedDir: UByte?, expectedFilenameOffset: Int) : Int { + builder.startTable(4) addExpectedFilename(builder, expectedFilenameOffset) addFileExtension(builder, fileExtensionOffset) addMimeType(builder, mimeTypeOffset) - addData(builder, dataOffset) expectedDir?.run { addExpectedDir(builder, expectedDir) } return endSaveFileNotification(builder) } @JvmStatic - fun startSaveFileNotification(builder: FlatBufferBuilder) = builder.startTable(5) - @JvmStatic - fun addData(builder: FlatBufferBuilder, data: Int) = builder.addOffset(0, data, 0) - @JvmStatic - fun createDataVector(builder: FlatBufferBuilder, data: UByteArray) : Int { - builder.startVector(1, data.size, 1) - for (i in data.size - 1 downTo 0) { - builder.addByte(data[i].toByte()) - } - return builder.endVector() - } - @JvmStatic - fun startDataVector(builder: FlatBufferBuilder, numElems: Int) = builder.startVector(1, numElems, 1) + fun startSaveFileNotification(builder: FlatBufferBuilder) = builder.startTable(4) @JvmStatic - fun addMimeType(builder: FlatBufferBuilder, mimeType: Int) = builder.addOffset(1, mimeType, 0) + fun addMimeType(builder: FlatBufferBuilder, mimeType: Int) = builder.addOffset(0, mimeType, 0) @JvmStatic - fun addFileExtension(builder: FlatBufferBuilder, fileExtension: Int) = builder.addOffset(2, fileExtension, 0) + fun addFileExtension(builder: FlatBufferBuilder, fileExtension: Int) = builder.addOffset(1, fileExtension, 0) @JvmStatic - fun addExpectedDir(builder: FlatBufferBuilder, expectedDir: UByte) = builder.addByte(3, expectedDir.toByte(), 0) + fun addExpectedDir(builder: FlatBufferBuilder, expectedDir: UByte) = builder.addByte(2, expectedDir.toByte(), 0) @JvmStatic - fun addExpectedFilename(builder: FlatBufferBuilder, expectedFilename: Int) = builder.addOffset(4, expectedFilename, 0) + fun addExpectedFilename(builder: FlatBufferBuilder, expectedFilename: Int) = builder.addOffset(3, expectedFilename, 0) @JvmStatic fun endSaveFileNotification(builder: FlatBufferBuilder) : Int { val o = builder.endTable() diff --git a/protocol/kotlin/src/solarxr_protocol/rpc/SaveFileResponse.kt b/protocol/kotlin/src/solarxr_protocol/rpc/SaveFileResponse.kt new file mode 100644 index 00000000..6dbe5ee5 --- /dev/null +++ b/protocol/kotlin/src/solarxr_protocol/rpc/SaveFileResponse.kt @@ -0,0 +1,55 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +package solarxr_protocol.rpc + +import java.nio.* +import kotlin.math.sign +import com.google.flatbuffers.* + +@Suppress("unused") +class SaveFileResponse : Table() { + + fun __init(_i: Int, _bb: ByteBuffer) { + __reset(_i, _bb) + } + fun __assign(_i: Int, _bb: ByteBuffer) : SaveFileResponse { + __init(_i, _bb) + return this + } + /** + * Where to save the file, if null, server will choose where to save it + */ + val path : String? + get() { + val o = __offset(4) + return if (o != 0) __string(o + bb_pos) else null + } + val pathAsByteBuffer : ByteBuffer get() = __vector_as_bytebuffer(4, 1) + fun pathInByteBuffer(_bb: ByteBuffer) : ByteBuffer = __vector_in_bytebuffer(_bb, 4, 1) + companion object { + @JvmStatic + fun validateVersion() = Constants.FLATBUFFERS_22_10_26() + @JvmStatic + fun getRootAsSaveFileResponse(_bb: ByteBuffer): SaveFileResponse = getRootAsSaveFileResponse(_bb, SaveFileResponse()) + @JvmStatic + fun getRootAsSaveFileResponse(_bb: ByteBuffer, obj: SaveFileResponse): SaveFileResponse { + _bb.order(ByteOrder.LITTLE_ENDIAN) + return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)) + } + @JvmStatic + fun createSaveFileResponse(builder: FlatBufferBuilder, pathOffset: Int) : Int { + builder.startTable(1) + addPath(builder, pathOffset) + return endSaveFileResponse(builder) + } + @JvmStatic + fun startSaveFileResponse(builder: FlatBufferBuilder) = builder.startTable(1) + @JvmStatic + fun addPath(builder: FlatBufferBuilder, path: Int) = builder.addOffset(0, path, 0) + @JvmStatic + fun endSaveFileResponse(builder: FlatBufferBuilder) : Int { + val o = builder.endTable() + return o + } + } +} diff --git a/protocol/rust/src/generated/mod.rs b/protocol/rust/src/generated/mod.rs index 93d66a65..f0dfd324 100644 --- a/protocol/rust/src/generated/mod.rs +++ b/protocol/rust/src/generated/mod.rs @@ -278,6 +278,8 @@ pub mod solarxr_protocol { pub use self::clear_mounting_reset_request_generated::*; mod save_file_notification_generated; pub use self::save_file_notification_generated::*; + mod save_file_response_generated; + pub use self::save_file_response_generated::*; } // rpc mod message_bundle_generated; pub use self::message_bundle_generated::*; diff --git a/protocol/rust/src/generated/solarxr_protocol/rpc/save_file_notification_generated.rs b/protocol/rust/src/generated/solarxr_protocol/rpc/save_file_notification_generated.rs index d3b2204f..0faf4189 100644 --- a/protocol/rust/src/generated/solarxr_protocol/rpc/save_file_notification_generated.rs +++ b/protocol/rust/src/generated/solarxr_protocol/rpc/save_file_notification_generated.rs @@ -26,11 +26,10 @@ impl<'a> flatbuffers::Follow<'a> for SaveFileNotification<'a> { } impl<'a> SaveFileNotification<'a> { - pub const VT_DATA: flatbuffers::VOffsetT = 4; - pub const VT_MIME_TYPE: flatbuffers::VOffsetT = 6; - pub const VT_FILE_EXTENSION: flatbuffers::VOffsetT = 8; - pub const VT_EXPECTED_DIR: flatbuffers::VOffsetT = 10; - pub const VT_EXPECTED_FILENAME: flatbuffers::VOffsetT = 12; + pub const VT_MIME_TYPE: flatbuffers::VOffsetT = 4; + pub const VT_FILE_EXTENSION: flatbuffers::VOffsetT = 6; + pub const VT_EXPECTED_DIR: flatbuffers::VOffsetT = 8; + pub const VT_EXPECTED_FILENAME: flatbuffers::VOffsetT = 10; #[inline] pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { @@ -45,20 +44,11 @@ impl<'a> SaveFileNotification<'a> { if let Some(x) = args.expected_filename { builder.add_expected_filename(x); } if let Some(x) = args.file_extension { builder.add_file_extension(x); } if let Some(x) = args.mime_type { builder.add_mime_type(x); } - if let Some(x) = args.data { builder.add_data(x); } if let Some(x) = args.expected_dir { builder.add_expected_dir(x); } builder.finish() } - /// Binary data of the file - #[inline] - pub fn data(&self) -> Option> { - // Safety: - // Created from valid Table for this object - // which contains a valid value in this slot - unsafe { self._tab.get::>>(SaveFileNotification::VT_DATA, None)} - } /// MIME type of file if one exists, use `file_extension` otherwise #[inline] pub fn mime_type(&self) -> Option<&'a str> { @@ -100,7 +90,6 @@ impl flatbuffers::Verifiable for SaveFileNotification<'_> { ) -> Result<(), flatbuffers::InvalidFlatbuffer> { use self::flatbuffers::Verifiable; v.visit_table(pos)? - .visit_field::>>("data", Self::VT_DATA, false)? .visit_field::>("mime_type", Self::VT_MIME_TYPE, false)? .visit_field::>("file_extension", Self::VT_FILE_EXTENSION, false)? .visit_field::("expected_dir", Self::VT_EXPECTED_DIR, false)? @@ -110,7 +99,6 @@ impl flatbuffers::Verifiable for SaveFileNotification<'_> { } } pub struct SaveFileNotificationArgs<'a> { - pub data: Option>>, pub mime_type: Option>, pub file_extension: Option>, pub expected_dir: Option, @@ -120,7 +108,6 @@ impl<'a> Default for SaveFileNotificationArgs<'a> { #[inline] fn default() -> Self { SaveFileNotificationArgs { - data: None, mime_type: None, file_extension: None, expected_dir: None, @@ -134,10 +121,6 @@ pub struct SaveFileNotificationBuilder<'a: 'b, 'b> { start_: flatbuffers::WIPOffset, } impl<'a: 'b, 'b> SaveFileNotificationBuilder<'a, 'b> { - #[inline] - pub fn add_data(&mut self, data: flatbuffers::WIPOffset>) { - self.fbb_.push_slot_always::>(SaveFileNotification::VT_DATA, data); - } #[inline] pub fn add_mime_type(&mut self, mime_type: flatbuffers::WIPOffset<&'b str>) { self.fbb_.push_slot_always::>(SaveFileNotification::VT_MIME_TYPE, mime_type); @@ -172,7 +155,6 @@ impl<'a: 'b, 'b> SaveFileNotificationBuilder<'a, 'b> { impl core::fmt::Debug for SaveFileNotification<'_> { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { let mut ds = f.debug_struct("SaveFileNotification"); - ds.field("data", &self.data()); ds.field("mime_type", &self.mime_type()); ds.field("file_extension", &self.file_extension()); ds.field("expected_dir", &self.expected_dir()); diff --git a/protocol/rust/src/generated/solarxr_protocol/rpc/save_file_response_generated.rs b/protocol/rust/src/generated/solarxr_protocol/rpc/save_file_response_generated.rs new file mode 100644 index 00000000..2889cfa4 --- /dev/null +++ b/protocol/rust/src/generated/solarxr_protocol/rpc/save_file_response_generated.rs @@ -0,0 +1,109 @@ +// automatically generated by the FlatBuffers compiler, do not modify +// @generated +extern crate alloc; +extern crate flatbuffers; +use alloc::boxed::Box; +use alloc::string::{String, ToString}; +use alloc::vec::Vec; +use core::mem; +use core::cmp::Ordering; +use self::flatbuffers::{EndianScalar, Follow}; +use super::*; +pub enum SaveFileResponseOffset {} +#[derive(Copy, Clone, PartialEq)] + +pub struct SaveFileResponse<'a> { + pub _tab: flatbuffers::Table<'a>, +} + +impl<'a> flatbuffers::Follow<'a> for SaveFileResponse<'a> { + type Inner = SaveFileResponse<'a>; + #[inline] + unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { + Self { _tab: flatbuffers::Table::new(buf, loc) } + } +} + +impl<'a> SaveFileResponse<'a> { + pub const VT_PATH: flatbuffers::VOffsetT = 4; + + #[inline] + pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + SaveFileResponse { _tab: table } + } + #[allow(unused_mut)] + pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( + _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, + args: &'args SaveFileResponseArgs<'args> + ) -> flatbuffers::WIPOffset> { + let mut builder = SaveFileResponseBuilder::new(_fbb); + if let Some(x) = args.path { builder.add_path(x); } + builder.finish() + } + + + /// Where to save the file, if null, server will choose where to save it + #[inline] + pub fn path(&self) -> Option<&'a str> { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::>(SaveFileResponse::VT_PATH, None)} + } +} + +impl flatbuffers::Verifiable for SaveFileResponse<'_> { + #[inline] + fn run_verifier( + v: &mut flatbuffers::Verifier, pos: usize + ) -> Result<(), flatbuffers::InvalidFlatbuffer> { + use self::flatbuffers::Verifiable; + v.visit_table(pos)? + .visit_field::>("path", Self::VT_PATH, false)? + .finish(); + Ok(()) + } +} +pub struct SaveFileResponseArgs<'a> { + pub path: Option>, +} +impl<'a> Default for SaveFileResponseArgs<'a> { + #[inline] + fn default() -> Self { + SaveFileResponseArgs { + path: None, + } + } +} + +pub struct SaveFileResponseBuilder<'a: 'b, 'b> { + fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, + start_: flatbuffers::WIPOffset, +} +impl<'a: 'b, 'b> SaveFileResponseBuilder<'a, 'b> { + #[inline] + pub fn add_path(&mut self, path: flatbuffers::WIPOffset<&'b str>) { + self.fbb_.push_slot_always::>(SaveFileResponse::VT_PATH, path); + } + #[inline] + pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> SaveFileResponseBuilder<'a, 'b> { + let start = _fbb.start_table(); + SaveFileResponseBuilder { + fbb_: _fbb, + start_: start, + } + } + #[inline] + pub fn finish(self) -> flatbuffers::WIPOffset> { + let o = self.fbb_.end_table(self.start_); + flatbuffers::WIPOffset::new(o.value()) + } +} + +impl core::fmt::Debug for SaveFileResponse<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + let mut ds = f.debug_struct("SaveFileResponse"); + ds.field("path", &self.path()); + ds.finish() + } +} diff --git a/protocol/typescript/src/all_generated.ts b/protocol/typescript/src/all_generated.ts index 82cb3b6d..27e1f350 100644 --- a/protocol/typescript/src/all_generated.ts +++ b/protocol/typescript/src/all_generated.ts @@ -85,6 +85,7 @@ export { ResetType } from './solarxr-protocol/rpc/reset-type.js'; export { RpcMessage, unionToRpcMessage, unionListToRpcMessage } from './solarxr-protocol/rpc/rpc-message.js'; export { RpcMessageHeader, RpcMessageHeaderT } from './solarxr-protocol/rpc/rpc-message-header.js'; export { SaveFileNotification, SaveFileNotificationT } from './solarxr-protocol/rpc/save-file-notification.js'; +export { SaveFileResponse, SaveFileResponseT } from './solarxr-protocol/rpc/save-file-response.js'; export { SerialDevice, SerialDeviceT } from './solarxr-protocol/rpc/serial-device.js'; export { SerialDevicesRequest, SerialDevicesRequestT } from './solarxr-protocol/rpc/serial-devices-request.js'; export { SerialDevicesResponse, SerialDevicesResponseT } from './solarxr-protocol/rpc/serial-devices-response.js'; diff --git a/protocol/typescript/src/solarxr-protocol/rpc/save-file-notification.ts b/protocol/typescript/src/solarxr-protocol/rpc/save-file-notification.ts index 619e524e..0e63c5f2 100644 --- a/protocol/typescript/src/solarxr-protocol/rpc/save-file-notification.ts +++ b/protocol/typescript/src/solarxr-protocol/rpc/save-file-notification.ts @@ -26,31 +26,13 @@ static getSizePrefixedRootAsSaveFileNotification(bb:flatbuffers.ByteBuffer, obj? return (obj || new SaveFileNotification()).__init(bb.readInt32(bb.position()) + bb.position(), bb); } -/** - * Binary data of the file - */ -data(index: number):number|null { - const offset = this.bb!.__offset(this.bb_pos, 4); - return offset ? this.bb!.readUint8(this.bb!.__vector(this.bb_pos + offset) + index) : 0; -} - -dataLength():number { - const offset = this.bb!.__offset(this.bb_pos, 4); - return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; -} - -dataArray():Uint8Array|null { - const offset = this.bb!.__offset(this.bb_pos, 4); - return offset ? new Uint8Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null; -} - /** * MIME type of file if one exists, use `file_extension` otherwise */ mimeType():string|null mimeType(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null mimeType(optionalEncoding?:any):string|Uint8Array|null { - const offset = this.bb!.__offset(this.bb_pos, 6); + const offset = this.bb!.__offset(this.bb_pos, 4); return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; } @@ -60,7 +42,7 @@ mimeType(optionalEncoding?:any):string|Uint8Array|null { fileExtension():string|null fileExtension(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null fileExtension(optionalEncoding?:any):string|Uint8Array|null { - const offset = this.bb!.__offset(this.bb_pos, 8); + const offset = this.bb!.__offset(this.bb_pos, 6); return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; } @@ -68,7 +50,7 @@ fileExtension(optionalEncoding?:any):string|Uint8Array|null { * Directory recommended to save the file on */ expectedDir():ComputerDirectory|null { - const offset = this.bb!.__offset(this.bb_pos, 10); + const offset = this.bb!.__offset(this.bb_pos, 8); return offset ? this.bb!.readUint8(this.bb_pos + offset) : null; } @@ -78,44 +60,28 @@ expectedDir():ComputerDirectory|null { expectedFilename():string|null expectedFilename(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null expectedFilename(optionalEncoding?:any):string|Uint8Array|null { - const offset = this.bb!.__offset(this.bb_pos, 12); + const offset = this.bb!.__offset(this.bb_pos, 10); return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; } static startSaveFileNotification(builder:flatbuffers.Builder) { - builder.startObject(5); -} - -static addData(builder:flatbuffers.Builder, dataOffset:flatbuffers.Offset) { - builder.addFieldOffset(0, dataOffset, 0); -} - -static createDataVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset { - builder.startVector(1, data.length, 1); - for (let i = data.length - 1; i >= 0; i--) { - builder.addInt8(data[i]!); - } - return builder.endVector(); -} - -static startDataVector(builder:flatbuffers.Builder, numElems:number) { - builder.startVector(1, numElems, 1); + builder.startObject(4); } static addMimeType(builder:flatbuffers.Builder, mimeTypeOffset:flatbuffers.Offset) { - builder.addFieldOffset(1, mimeTypeOffset, 0); + builder.addFieldOffset(0, mimeTypeOffset, 0); } static addFileExtension(builder:flatbuffers.Builder, fileExtensionOffset:flatbuffers.Offset) { - builder.addFieldOffset(2, fileExtensionOffset, 0); + builder.addFieldOffset(1, fileExtensionOffset, 0); } static addExpectedDir(builder:flatbuffers.Builder, expectedDir:ComputerDirectory) { - builder.addFieldInt8(3, expectedDir, 0); + builder.addFieldInt8(2, expectedDir, 0); } static addExpectedFilename(builder:flatbuffers.Builder, expectedFilenameOffset:flatbuffers.Offset) { - builder.addFieldOffset(4, expectedFilenameOffset, 0); + builder.addFieldOffset(3, expectedFilenameOffset, 0); } static endSaveFileNotification(builder:flatbuffers.Builder):flatbuffers.Offset { @@ -123,9 +89,8 @@ static endSaveFileNotification(builder:flatbuffers.Builder):flatbuffers.Offset { return offset; } -static createSaveFileNotification(builder:flatbuffers.Builder, dataOffset:flatbuffers.Offset, mimeTypeOffset:flatbuffers.Offset, fileExtensionOffset:flatbuffers.Offset, expectedDir:ComputerDirectory|null, expectedFilenameOffset:flatbuffers.Offset):flatbuffers.Offset { +static createSaveFileNotification(builder:flatbuffers.Builder, mimeTypeOffset:flatbuffers.Offset, fileExtensionOffset:flatbuffers.Offset, expectedDir:ComputerDirectory|null, expectedFilenameOffset:flatbuffers.Offset):flatbuffers.Offset { SaveFileNotification.startSaveFileNotification(builder); - SaveFileNotification.addData(builder, dataOffset); SaveFileNotification.addMimeType(builder, mimeTypeOffset); SaveFileNotification.addFileExtension(builder, fileExtensionOffset); if (expectedDir !== null) @@ -136,7 +101,6 @@ static createSaveFileNotification(builder:flatbuffers.Builder, dataOffset:flatbu unpack(): SaveFileNotificationT { return new SaveFileNotificationT( - this.bb!.createScalarList(this.data.bind(this), this.dataLength()), this.mimeType(), this.fileExtension(), this.expectedDir(), @@ -146,7 +110,6 @@ unpack(): SaveFileNotificationT { unpackTo(_o: SaveFileNotificationT): void { - _o.data = this.bb!.createScalarList(this.data.bind(this), this.dataLength()); _o.mimeType = this.mimeType(); _o.fileExtension = this.fileExtension(); _o.expectedDir = this.expectedDir(); @@ -156,7 +119,6 @@ unpackTo(_o: SaveFileNotificationT): void { export class SaveFileNotificationT implements flatbuffers.IGeneratedObject { constructor( - public data: (number)[] = [], public mimeType: string|Uint8Array|null = null, public fileExtension: string|Uint8Array|null = null, public expectedDir: ComputerDirectory|null = null, @@ -165,13 +127,11 @@ constructor( pack(builder:flatbuffers.Builder): flatbuffers.Offset { - const data = SaveFileNotification.createDataVector(builder, this.data); const mimeType = (this.mimeType !== null ? builder.createString(this.mimeType!) : 0); const fileExtension = (this.fileExtension !== null ? builder.createString(this.fileExtension!) : 0); const expectedFilename = (this.expectedFilename !== null ? builder.createString(this.expectedFilename!) : 0); return SaveFileNotification.createSaveFileNotification(builder, - data, mimeType, fileExtension, this.expectedDir, diff --git a/protocol/typescript/src/solarxr-protocol/rpc/save-file-response.ts b/protocol/typescript/src/solarxr-protocol/rpc/save-file-response.ts new file mode 100644 index 00000000..e7387147 --- /dev/null +++ b/protocol/typescript/src/solarxr-protocol/rpc/save-file-response.ts @@ -0,0 +1,79 @@ +// automatically generated by the FlatBuffers compiler, do not modify + +import * as flatbuffers from 'flatbuffers'; + + + +export class SaveFileResponse implements flatbuffers.IUnpackableObject { + bb: flatbuffers.ByteBuffer|null = null; + bb_pos = 0; + __init(i:number, bb:flatbuffers.ByteBuffer):SaveFileResponse { + this.bb_pos = i; + this.bb = bb; + return this; +} + +static getRootAsSaveFileResponse(bb:flatbuffers.ByteBuffer, obj?:SaveFileResponse):SaveFileResponse { + return (obj || new SaveFileResponse()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +static getSizePrefixedRootAsSaveFileResponse(bb:flatbuffers.ByteBuffer, obj?:SaveFileResponse):SaveFileResponse { + bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); + return (obj || new SaveFileResponse()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +} + +/** + * Where to save the file, if null, server will choose where to save it + */ +path():string|null +path(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null +path(optionalEncoding?:any):string|Uint8Array|null { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; +} + +static startSaveFileResponse(builder:flatbuffers.Builder) { + builder.startObject(1); +} + +static addPath(builder:flatbuffers.Builder, pathOffset:flatbuffers.Offset) { + builder.addFieldOffset(0, pathOffset, 0); +} + +static endSaveFileResponse(builder:flatbuffers.Builder):flatbuffers.Offset { + const offset = builder.endObject(); + return offset; +} + +static createSaveFileResponse(builder:flatbuffers.Builder, pathOffset:flatbuffers.Offset):flatbuffers.Offset { + SaveFileResponse.startSaveFileResponse(builder); + SaveFileResponse.addPath(builder, pathOffset); + return SaveFileResponse.endSaveFileResponse(builder); +} + +unpack(): SaveFileResponseT { + return new SaveFileResponseT( + this.path() + ); +} + + +unpackTo(_o: SaveFileResponseT): void { + _o.path = this.path(); +} +} + +export class SaveFileResponseT implements flatbuffers.IGeneratedObject { +constructor( + public path: string|Uint8Array|null = null +){} + + +pack(builder:flatbuffers.Builder): flatbuffers.Offset { + const path = (this.path !== null ? builder.createString(this.path!) : 0); + + return SaveFileResponse.createSaveFileResponse(builder, + path + ); +} +} diff --git a/schema/rpc.fbs b/schema/rpc.fbs index c4f66fbd..c47f4970 100644 --- a/schema/rpc.fbs +++ b/schema/rpc.fbs @@ -531,8 +531,6 @@ enum ComputerDirectory: uint8 { /// Used for the server to save a file and have it prompt in the user side table SaveFileNotification { - /// Binary data of the file - data: [uint8]; /// MIME type of file if one exists, use `file_extension` otherwise mime_type: string; /// Use MIME type preferably if one exists @@ -542,3 +540,8 @@ table SaveFileNotification { /// Recommended filename expected_filename: string; } + +table SaveFileResponse { + /// Where to save the file, if null, server will choose where to save it + path: string; +} From e54be920d92ee7c0555163f2797225488f283035 Mon Sep 17 00:00:00 2001 From: ImUrX Date: Thu, 3 Aug 2023 02:30:33 -0300 Subject: [PATCH 2/5] add canceled field --- .../generated/all_generated.h | 21 +++++++++++--- .../rpc/SaveFileResponse.java | 19 ++++++++++--- .../rpc/SaveFileResponseT.java | 6 ++++ .../solarxr_protocol/rpc/SaveFileResponse.kt | 17 +++++++++-- .../rpc/save_file_response_generated.rs | 18 ++++++++++++ .../rpc/save-file-response.ts | 28 +++++++++++++++---- schema/rpc.fbs | 2 ++ 7 files changed, 95 insertions(+), 16 deletions(-) diff --git a/protocol/cpp/include/solarxr_protocol/generated/all_generated.h b/protocol/cpp/include/solarxr_protocol/generated/all_generated.h index e1caa6df..c2ce7fad 100644 --- a/protocol/cpp/include/solarxr_protocol/generated/all_generated.h +++ b/protocol/cpp/include/solarxr_protocol/generated/all_generated.h @@ -8269,16 +8269,22 @@ inline flatbuffers::Offset CreateSaveFileNotificationDirec struct SaveFileResponse FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef SaveFileResponseBuilder Builder; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_PATH = 4 + VT_PATH = 4, + VT_CANCELED = 6 }; /// Where to save the file, if null, server will choose where to save it const flatbuffers::String *path() const { return GetPointer(VT_PATH); } + /// If the user canceled the file save + flatbuffers::Optional canceled() const { + return GetOptional(VT_CANCELED); + } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyOffset(verifier, VT_PATH) && verifier.VerifyString(path()) && + VerifyField(verifier, VT_CANCELED, 1) && verifier.EndTable(); } }; @@ -8290,6 +8296,9 @@ struct SaveFileResponseBuilder { void add_path(flatbuffers::Offset path) { fbb_.AddOffset(SaveFileResponse::VT_PATH, path); } + void add_canceled(bool canceled) { + fbb_.AddElement(SaveFileResponse::VT_CANCELED, static_cast(canceled)); + } explicit SaveFileResponseBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); @@ -8303,19 +8312,23 @@ struct SaveFileResponseBuilder { inline flatbuffers::Offset CreateSaveFileResponse( flatbuffers::FlatBufferBuilder &_fbb, - flatbuffers::Offset path = 0) { + flatbuffers::Offset path = 0, + flatbuffers::Optional canceled = flatbuffers::nullopt) { SaveFileResponseBuilder builder_(_fbb); builder_.add_path(path); + if(canceled) { builder_.add_canceled(*canceled); } return builder_.Finish(); } inline flatbuffers::Offset CreateSaveFileResponseDirect( flatbuffers::FlatBufferBuilder &_fbb, - const char *path = nullptr) { + const char *path = nullptr, + flatbuffers::Optional canceled = flatbuffers::nullopt) { auto path__ = path ? _fbb.CreateString(path) : 0; return solarxr_protocol::rpc::CreateSaveFileResponse( _fbb, - path__); + path__, + canceled); } } // namespace rpc diff --git a/protocol/java/src/solarxr_protocol/rpc/SaveFileResponse.java b/protocol/java/src/solarxr_protocol/rpc/SaveFileResponse.java index 05d72f31..2172d825 100644 --- a/protocol/java/src/solarxr_protocol/rpc/SaveFileResponse.java +++ b/protocol/java/src/solarxr_protocol/rpc/SaveFileResponse.java @@ -21,16 +21,24 @@ public final class SaveFileResponse extends Table { public String path() { int o = __offset(4); return o != 0 ? __string(o + bb_pos) : null; } public ByteBuffer pathAsByteBuffer() { return __vector_as_bytebuffer(4, 1); } public ByteBuffer pathInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 4, 1); } + /** + * If the user canceled the file save + */ + public boolean hasCanceled() { return 0 != __offset(6); } + public boolean canceled() { int o = __offset(6); return o != 0 ? 0!=bb.get(o + bb_pos) : false; } public static int createSaveFileResponse(FlatBufferBuilder builder, - int pathOffset) { - builder.startTable(1); + int pathOffset, + boolean canceled) { + builder.startTable(2); SaveFileResponse.addPath(builder, pathOffset); + SaveFileResponse.addCanceled(builder, canceled); return SaveFileResponse.endSaveFileResponse(builder); } - public static void startSaveFileResponse(FlatBufferBuilder builder) { builder.startTable(1); } + public static void startSaveFileResponse(FlatBufferBuilder builder) { builder.startTable(2); } public static void addPath(FlatBufferBuilder builder, int pathOffset) { builder.addOffset(0, pathOffset, 0); } + public static void addCanceled(FlatBufferBuilder builder, boolean canceled) { builder.addBoolean(1, canceled, false); } public static int endSaveFileResponse(FlatBufferBuilder builder) { int o = builder.endTable(); return o; @@ -50,13 +58,16 @@ public SaveFileResponseT unpack() { public void unpackTo(SaveFileResponseT _o) { String _oPath = path(); _o.setPath(_oPath); + Boolean _oCanceled = hasCanceled() ? canceled() : null; + _o.setCanceled(_oCanceled); } public static int pack(FlatBufferBuilder builder, SaveFileResponseT _o) { if (_o == null) return 0; int _path = _o.getPath() == null ? 0 : builder.createString(_o.getPath()); return createSaveFileResponse( builder, - _path); + _path, + _o.getCanceled()); } } diff --git a/protocol/java/src/solarxr_protocol/rpc/SaveFileResponseT.java b/protocol/java/src/solarxr_protocol/rpc/SaveFileResponseT.java index 7cfc1616..6a74c5b5 100644 --- a/protocol/java/src/solarxr_protocol/rpc/SaveFileResponseT.java +++ b/protocol/java/src/solarxr_protocol/rpc/SaveFileResponseT.java @@ -9,14 +9,20 @@ public class SaveFileResponseT { private String path; + private Boolean canceled; public String getPath() { return path; } public void setPath(String path) { this.path = path; } + public Boolean getCanceled() { return canceled; } + + public void setCanceled(Boolean canceled) { this.canceled = canceled; } + public SaveFileResponseT() { this.path = null; + this.canceled = null; } } diff --git a/protocol/kotlin/src/solarxr_protocol/rpc/SaveFileResponse.kt b/protocol/kotlin/src/solarxr_protocol/rpc/SaveFileResponse.kt index 6dbe5ee5..5b9a1840 100644 --- a/protocol/kotlin/src/solarxr_protocol/rpc/SaveFileResponse.kt +++ b/protocol/kotlin/src/solarxr_protocol/rpc/SaveFileResponse.kt @@ -26,6 +26,14 @@ class SaveFileResponse : Table() { } val pathAsByteBuffer : ByteBuffer get() = __vector_as_bytebuffer(4, 1) fun pathInByteBuffer(_bb: ByteBuffer) : ByteBuffer = __vector_in_bytebuffer(_bb, 4, 1) + /** + * If the user canceled the file save + */ + val canceled : Boolean? + get() { + val o = __offset(6) + return if(o != 0) 0.toByte() != bb.get(o + bb_pos) else null + } companion object { @JvmStatic fun validateVersion() = Constants.FLATBUFFERS_22_10_26() @@ -37,16 +45,19 @@ class SaveFileResponse : Table() { return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)) } @JvmStatic - fun createSaveFileResponse(builder: FlatBufferBuilder, pathOffset: Int) : Int { - builder.startTable(1) + fun createSaveFileResponse(builder: FlatBufferBuilder, pathOffset: Int, canceled: Boolean?) : Int { + builder.startTable(2) addPath(builder, pathOffset) + canceled?.run { addCanceled(builder, canceled) } return endSaveFileResponse(builder) } @JvmStatic - fun startSaveFileResponse(builder: FlatBufferBuilder) = builder.startTable(1) + fun startSaveFileResponse(builder: FlatBufferBuilder) = builder.startTable(2) @JvmStatic fun addPath(builder: FlatBufferBuilder, path: Int) = builder.addOffset(0, path, 0) @JvmStatic + fun addCanceled(builder: FlatBufferBuilder, canceled: Boolean) = builder.addBoolean(1, canceled, false) + @JvmStatic fun endSaveFileResponse(builder: FlatBufferBuilder) : Int { val o = builder.endTable() return o diff --git a/protocol/rust/src/generated/solarxr_protocol/rpc/save_file_response_generated.rs b/protocol/rust/src/generated/solarxr_protocol/rpc/save_file_response_generated.rs index 2889cfa4..14277e90 100644 --- a/protocol/rust/src/generated/solarxr_protocol/rpc/save_file_response_generated.rs +++ b/protocol/rust/src/generated/solarxr_protocol/rpc/save_file_response_generated.rs @@ -26,6 +26,7 @@ impl<'a> flatbuffers::Follow<'a> for SaveFileResponse<'a> { impl<'a> SaveFileResponse<'a> { pub const VT_PATH: flatbuffers::VOffsetT = 4; + pub const VT_CANCELED: flatbuffers::VOffsetT = 6; #[inline] pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { @@ -38,6 +39,7 @@ impl<'a> SaveFileResponse<'a> { ) -> flatbuffers::WIPOffset> { let mut builder = SaveFileResponseBuilder::new(_fbb); if let Some(x) = args.path { builder.add_path(x); } + if let Some(x) = args.canceled { builder.add_canceled(x); } builder.finish() } @@ -50,6 +52,14 @@ impl<'a> SaveFileResponse<'a> { // which contains a valid value in this slot unsafe { self._tab.get::>(SaveFileResponse::VT_PATH, None)} } + /// If the user canceled the file save + #[inline] + pub fn canceled(&self) -> Option { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(SaveFileResponse::VT_CANCELED, None)} + } } impl flatbuffers::Verifiable for SaveFileResponse<'_> { @@ -60,18 +70,21 @@ impl flatbuffers::Verifiable for SaveFileResponse<'_> { use self::flatbuffers::Verifiable; v.visit_table(pos)? .visit_field::>("path", Self::VT_PATH, false)? + .visit_field::("canceled", Self::VT_CANCELED, false)? .finish(); Ok(()) } } pub struct SaveFileResponseArgs<'a> { pub path: Option>, + pub canceled: Option, } impl<'a> Default for SaveFileResponseArgs<'a> { #[inline] fn default() -> Self { SaveFileResponseArgs { path: None, + canceled: None, } } } @@ -86,6 +99,10 @@ impl<'a: 'b, 'b> SaveFileResponseBuilder<'a, 'b> { self.fbb_.push_slot_always::>(SaveFileResponse::VT_PATH, path); } #[inline] + pub fn add_canceled(&mut self, canceled: bool) { + self.fbb_.push_slot_always::(SaveFileResponse::VT_CANCELED, canceled); + } + #[inline] pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> SaveFileResponseBuilder<'a, 'b> { let start = _fbb.start_table(); SaveFileResponseBuilder { @@ -104,6 +121,7 @@ impl core::fmt::Debug for SaveFileResponse<'_> { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { let mut ds = f.debug_struct("SaveFileResponse"); ds.field("path", &self.path()); + ds.field("canceled", &self.canceled()); ds.finish() } } diff --git a/protocol/typescript/src/solarxr-protocol/rpc/save-file-response.ts b/protocol/typescript/src/solarxr-protocol/rpc/save-file-response.ts index e7387147..58499dfc 100644 --- a/protocol/typescript/src/solarxr-protocol/rpc/save-file-response.ts +++ b/protocol/typescript/src/solarxr-protocol/rpc/save-file-response.ts @@ -32,40 +32,57 @@ path(optionalEncoding?:any):string|Uint8Array|null { return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; } +/** + * If the user canceled the file save + */ +canceled():boolean|null { + const offset = this.bb!.__offset(this.bb_pos, 6); + return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : null; +} + static startSaveFileResponse(builder:flatbuffers.Builder) { - builder.startObject(1); + builder.startObject(2); } static addPath(builder:flatbuffers.Builder, pathOffset:flatbuffers.Offset) { builder.addFieldOffset(0, pathOffset, 0); } +static addCanceled(builder:flatbuffers.Builder, canceled:boolean) { + builder.addFieldInt8(1, +canceled, 0); +} + static endSaveFileResponse(builder:flatbuffers.Builder):flatbuffers.Offset { const offset = builder.endObject(); return offset; } -static createSaveFileResponse(builder:flatbuffers.Builder, pathOffset:flatbuffers.Offset):flatbuffers.Offset { +static createSaveFileResponse(builder:flatbuffers.Builder, pathOffset:flatbuffers.Offset, canceled:boolean|null):flatbuffers.Offset { SaveFileResponse.startSaveFileResponse(builder); SaveFileResponse.addPath(builder, pathOffset); + if (canceled !== null) + SaveFileResponse.addCanceled(builder, canceled); return SaveFileResponse.endSaveFileResponse(builder); } unpack(): SaveFileResponseT { return new SaveFileResponseT( - this.path() + this.path(), + this.canceled() ); } unpackTo(_o: SaveFileResponseT): void { _o.path = this.path(); + _o.canceled = this.canceled(); } } export class SaveFileResponseT implements flatbuffers.IGeneratedObject { constructor( - public path: string|Uint8Array|null = null + public path: string|Uint8Array|null = null, + public canceled: boolean|null = null ){} @@ -73,7 +90,8 @@ pack(builder:flatbuffers.Builder): flatbuffers.Offset { const path = (this.path !== null ? builder.createString(this.path!) : 0); return SaveFileResponse.createSaveFileResponse(builder, - path + path, + this.canceled ); } } diff --git a/schema/rpc.fbs b/schema/rpc.fbs index c47f4970..cddb718f 100644 --- a/schema/rpc.fbs +++ b/schema/rpc.fbs @@ -544,4 +544,6 @@ table SaveFileNotification { table SaveFileResponse { /// Where to save the file, if null, server will choose where to save it path: string; + /// If the user canceled the file save + canceled: bool = null; } From ca130cedf18c1bc9b84af673abb13b12ccc71222 Mon Sep 17 00:00:00 2001 From: ImUrX Date: Thu, 3 Aug 2023 02:31:08 -0300 Subject: [PATCH 3/5] improve comment --- protocol/cpp/include/solarxr_protocol/generated/all_generated.h | 2 +- protocol/java/src/solarxr_protocol/rpc/SaveFileResponse.java | 2 +- protocol/kotlin/src/solarxr_protocol/rpc/SaveFileResponse.kt | 2 +- .../solarxr_protocol/rpc/save_file_response_generated.rs | 2 +- .../typescript/src/solarxr-protocol/rpc/save-file-response.ts | 2 +- schema/rpc.fbs | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/protocol/cpp/include/solarxr_protocol/generated/all_generated.h b/protocol/cpp/include/solarxr_protocol/generated/all_generated.h index c2ce7fad..72d759b7 100644 --- a/protocol/cpp/include/solarxr_protocol/generated/all_generated.h +++ b/protocol/cpp/include/solarxr_protocol/generated/all_generated.h @@ -8276,7 +8276,7 @@ struct SaveFileResponse FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { const flatbuffers::String *path() const { return GetPointer(VT_PATH); } - /// If the user canceled the file save + /// Iff false, the file save wwill be canceled flatbuffers::Optional canceled() const { return GetOptional(VT_CANCELED); } diff --git a/protocol/java/src/solarxr_protocol/rpc/SaveFileResponse.java b/protocol/java/src/solarxr_protocol/rpc/SaveFileResponse.java index 2172d825..b006ff8b 100644 --- a/protocol/java/src/solarxr_protocol/rpc/SaveFileResponse.java +++ b/protocol/java/src/solarxr_protocol/rpc/SaveFileResponse.java @@ -22,7 +22,7 @@ public final class SaveFileResponse extends Table { public ByteBuffer pathAsByteBuffer() { return __vector_as_bytebuffer(4, 1); } public ByteBuffer pathInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 4, 1); } /** - * If the user canceled the file save + * Iff false, the file save wwill be canceled */ public boolean hasCanceled() { return 0 != __offset(6); } public boolean canceled() { int o = __offset(6); return o != 0 ? 0!=bb.get(o + bb_pos) : false; } diff --git a/protocol/kotlin/src/solarxr_protocol/rpc/SaveFileResponse.kt b/protocol/kotlin/src/solarxr_protocol/rpc/SaveFileResponse.kt index 5b9a1840..ee13777c 100644 --- a/protocol/kotlin/src/solarxr_protocol/rpc/SaveFileResponse.kt +++ b/protocol/kotlin/src/solarxr_protocol/rpc/SaveFileResponse.kt @@ -27,7 +27,7 @@ class SaveFileResponse : Table() { val pathAsByteBuffer : ByteBuffer get() = __vector_as_bytebuffer(4, 1) fun pathInByteBuffer(_bb: ByteBuffer) : ByteBuffer = __vector_in_bytebuffer(_bb, 4, 1) /** - * If the user canceled the file save + * Iff false, the file save wwill be canceled */ val canceled : Boolean? get() { diff --git a/protocol/rust/src/generated/solarxr_protocol/rpc/save_file_response_generated.rs b/protocol/rust/src/generated/solarxr_protocol/rpc/save_file_response_generated.rs index 14277e90..37c98c8b 100644 --- a/protocol/rust/src/generated/solarxr_protocol/rpc/save_file_response_generated.rs +++ b/protocol/rust/src/generated/solarxr_protocol/rpc/save_file_response_generated.rs @@ -52,7 +52,7 @@ impl<'a> SaveFileResponse<'a> { // which contains a valid value in this slot unsafe { self._tab.get::>(SaveFileResponse::VT_PATH, None)} } - /// If the user canceled the file save + /// Iff false, the file save wwill be canceled #[inline] pub fn canceled(&self) -> Option { // Safety: diff --git a/protocol/typescript/src/solarxr-protocol/rpc/save-file-response.ts b/protocol/typescript/src/solarxr-protocol/rpc/save-file-response.ts index 58499dfc..e5a8b9af 100644 --- a/protocol/typescript/src/solarxr-protocol/rpc/save-file-response.ts +++ b/protocol/typescript/src/solarxr-protocol/rpc/save-file-response.ts @@ -33,7 +33,7 @@ path(optionalEncoding?:any):string|Uint8Array|null { } /** - * If the user canceled the file save + * Iff false, the file save wwill be canceled */ canceled():boolean|null { const offset = this.bb!.__offset(this.bb_pos, 6); diff --git a/schema/rpc.fbs b/schema/rpc.fbs index cddb718f..0bdd20aa 100644 --- a/schema/rpc.fbs +++ b/schema/rpc.fbs @@ -544,6 +544,6 @@ table SaveFileNotification { table SaveFileResponse { /// Where to save the file, if null, server will choose where to save it path: string; - /// If the user canceled the file save + /// Iff false, the file save wwill be canceled canceled: bool = null; } From 24f53346609d68593156e7bcbe7a2813143ba3f8 Mon Sep 17 00:00:00 2001 From: ImUrX Date: Thu, 3 Aug 2023 03:02:05 -0300 Subject: [PATCH 4/5] sigh --- .../generated/all_generated.h | 32 ++++++------ ...FileResponse.java => SaveFileRequest.java} | 36 ++++++------- ...leResponseT.java => SaveFileRequestT.java} | 4 +- ...SaveFileResponse.kt => SaveFileRequest.kt} | 18 +++---- protocol/rust/src/generated/mod.rs | 4 +- ...ated.rs => save_file_request_generated.rs} | 50 +++++++++---------- protocol/typescript/src/all_generated.ts | 2 +- ...-file-response.ts => save-file-request.ts} | 38 +++++++------- schema/rpc.fbs | 4 +- 9 files changed, 94 insertions(+), 94 deletions(-) rename protocol/java/src/solarxr_protocol/rpc/{SaveFileResponse.java => SaveFileRequest.java} (56%) rename protocol/java/src/solarxr_protocol/rpc/{SaveFileResponseT.java => SaveFileRequestT.java} (89%) rename protocol/kotlin/src/solarxr_protocol/rpc/{SaveFileResponse.kt => SaveFileRequest.kt} (71%) rename protocol/rust/src/generated/solarxr_protocol/rpc/{save_file_response_generated.rs => save_file_request_generated.rs} (70%) rename protocol/typescript/src/solarxr-protocol/rpc/{save-file-response.ts => save-file-request.ts} (53%) diff --git a/protocol/cpp/include/solarxr_protocol/generated/all_generated.h b/protocol/cpp/include/solarxr_protocol/generated/all_generated.h index 72d759b7..2a65fb0c 100644 --- a/protocol/cpp/include/solarxr_protocol/generated/all_generated.h +++ b/protocol/cpp/include/solarxr_protocol/generated/all_generated.h @@ -327,8 +327,8 @@ struct ClearMountingResetRequestBuilder; struct SaveFileNotification; struct SaveFileNotificationBuilder; -struct SaveFileResponse; -struct SaveFileResponseBuilder; +struct SaveFileRequest; +struct SaveFileRequestBuilder; } // namespace rpc @@ -8266,8 +8266,8 @@ inline flatbuffers::Offset CreateSaveFileNotificationDirec expected_filename__); } -struct SaveFileResponse FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef SaveFileResponseBuilder Builder; +struct SaveFileRequest FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { + typedef SaveFileRequestBuilder Builder; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_PATH = 4, VT_CANCELED = 6 @@ -8276,7 +8276,7 @@ struct SaveFileResponse FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { const flatbuffers::String *path() const { return GetPointer(VT_PATH); } - /// Iff false, the file save wwill be canceled + /// Iff false, the file save will be canceled flatbuffers::Optional canceled() const { return GetOptional(VT_CANCELED); } @@ -8289,43 +8289,43 @@ struct SaveFileResponse FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { } }; -struct SaveFileResponseBuilder { - typedef SaveFileResponse Table; +struct SaveFileRequestBuilder { + typedef SaveFileRequest Table; flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_path(flatbuffers::Offset path) { - fbb_.AddOffset(SaveFileResponse::VT_PATH, path); + fbb_.AddOffset(SaveFileRequest::VT_PATH, path); } void add_canceled(bool canceled) { - fbb_.AddElement(SaveFileResponse::VT_CANCELED, static_cast(canceled)); + fbb_.AddElement(SaveFileRequest::VT_CANCELED, static_cast(canceled)); } - explicit SaveFileResponseBuilder(flatbuffers::FlatBufferBuilder &_fbb) + explicit SaveFileRequestBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } - flatbuffers::Offset Finish() { + flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); + auto o = flatbuffers::Offset(end); return o; } }; -inline flatbuffers::Offset CreateSaveFileResponse( +inline flatbuffers::Offset CreateSaveFileRequest( flatbuffers::FlatBufferBuilder &_fbb, flatbuffers::Offset path = 0, flatbuffers::Optional canceled = flatbuffers::nullopt) { - SaveFileResponseBuilder builder_(_fbb); + SaveFileRequestBuilder builder_(_fbb); builder_.add_path(path); if(canceled) { builder_.add_canceled(*canceled); } return builder_.Finish(); } -inline flatbuffers::Offset CreateSaveFileResponseDirect( +inline flatbuffers::Offset CreateSaveFileRequestDirect( flatbuffers::FlatBufferBuilder &_fbb, const char *path = nullptr, flatbuffers::Optional canceled = flatbuffers::nullopt) { auto path__ = path ? _fbb.CreateString(path) : 0; - return solarxr_protocol::rpc::CreateSaveFileResponse( + return solarxr_protocol::rpc::CreateSaveFileRequest( _fbb, path__, canceled); diff --git a/protocol/java/src/solarxr_protocol/rpc/SaveFileResponse.java b/protocol/java/src/solarxr_protocol/rpc/SaveFileRequest.java similarity index 56% rename from protocol/java/src/solarxr_protocol/rpc/SaveFileResponse.java rename to protocol/java/src/solarxr_protocol/rpc/SaveFileRequest.java index b006ff8b..e14262f9 100644 --- a/protocol/java/src/solarxr_protocol/rpc/SaveFileResponse.java +++ b/protocol/java/src/solarxr_protocol/rpc/SaveFileRequest.java @@ -8,12 +8,12 @@ import com.google.flatbuffers.*; @SuppressWarnings("unused") -public final class SaveFileResponse extends Table { +public final class SaveFileRequest extends Table { public static void ValidateVersion() { Constants.FLATBUFFERS_22_10_26(); } - public static SaveFileResponse getRootAsSaveFileResponse(ByteBuffer _bb) { return getRootAsSaveFileResponse(_bb, new SaveFileResponse()); } - public static SaveFileResponse getRootAsSaveFileResponse(ByteBuffer _bb, SaveFileResponse obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); } + public static SaveFileRequest getRootAsSaveFileRequest(ByteBuffer _bb) { return getRootAsSaveFileRequest(_bb, new SaveFileRequest()); } + public static SaveFileRequest getRootAsSaveFileRequest(ByteBuffer _bb, SaveFileRequest obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); } public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); } - public SaveFileResponse __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; } + public SaveFileRequest __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; } /** * Where to save the file, if null, server will choose where to save it @@ -22,24 +22,24 @@ public final class SaveFileResponse extends Table { public ByteBuffer pathAsByteBuffer() { return __vector_as_bytebuffer(4, 1); } public ByteBuffer pathInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 4, 1); } /** - * Iff false, the file save wwill be canceled + * Iff false, the file save will be canceled */ public boolean hasCanceled() { return 0 != __offset(6); } public boolean canceled() { int o = __offset(6); return o != 0 ? 0!=bb.get(o + bb_pos) : false; } - public static int createSaveFileResponse(FlatBufferBuilder builder, + public static int createSaveFileRequest(FlatBufferBuilder builder, int pathOffset, boolean canceled) { builder.startTable(2); - SaveFileResponse.addPath(builder, pathOffset); - SaveFileResponse.addCanceled(builder, canceled); - return SaveFileResponse.endSaveFileResponse(builder); + SaveFileRequest.addPath(builder, pathOffset); + SaveFileRequest.addCanceled(builder, canceled); + return SaveFileRequest.endSaveFileRequest(builder); } - public static void startSaveFileResponse(FlatBufferBuilder builder) { builder.startTable(2); } + public static void startSaveFileRequest(FlatBufferBuilder builder) { builder.startTable(2); } public static void addPath(FlatBufferBuilder builder, int pathOffset) { builder.addOffset(0, pathOffset, 0); } public static void addCanceled(FlatBufferBuilder builder, boolean canceled) { builder.addBoolean(1, canceled, false); } - public static int endSaveFileResponse(FlatBufferBuilder builder) { + public static int endSaveFileRequest(FlatBufferBuilder builder) { int o = builder.endTable(); return o; } @@ -47,24 +47,24 @@ public static int endSaveFileResponse(FlatBufferBuilder builder) { public static final class Vector extends BaseVector { public Vector __assign(int _vector, int _element_size, ByteBuffer _bb) { __reset(_vector, _element_size, _bb); return this; } - public SaveFileResponse get(int j) { return get(new SaveFileResponse(), j); } - public SaveFileResponse get(SaveFileResponse obj, int j) { return obj.__assign(__indirect(__element(j), bb), bb); } + public SaveFileRequest get(int j) { return get(new SaveFileRequest(), j); } + public SaveFileRequest get(SaveFileRequest obj, int j) { return obj.__assign(__indirect(__element(j), bb), bb); } } - public SaveFileResponseT unpack() { - SaveFileResponseT _o = new SaveFileResponseT(); + public SaveFileRequestT unpack() { + SaveFileRequestT _o = new SaveFileRequestT(); unpackTo(_o); return _o; } - public void unpackTo(SaveFileResponseT _o) { + public void unpackTo(SaveFileRequestT _o) { String _oPath = path(); _o.setPath(_oPath); Boolean _oCanceled = hasCanceled() ? canceled() : null; _o.setCanceled(_oCanceled); } - public static int pack(FlatBufferBuilder builder, SaveFileResponseT _o) { + public static int pack(FlatBufferBuilder builder, SaveFileRequestT _o) { if (_o == null) return 0; int _path = _o.getPath() == null ? 0 : builder.createString(_o.getPath()); - return createSaveFileResponse( + return createSaveFileRequest( builder, _path, _o.getCanceled()); diff --git a/protocol/java/src/solarxr_protocol/rpc/SaveFileResponseT.java b/protocol/java/src/solarxr_protocol/rpc/SaveFileRequestT.java similarity index 89% rename from protocol/java/src/solarxr_protocol/rpc/SaveFileResponseT.java rename to protocol/java/src/solarxr_protocol/rpc/SaveFileRequestT.java index 6a74c5b5..0a790156 100644 --- a/protocol/java/src/solarxr_protocol/rpc/SaveFileResponseT.java +++ b/protocol/java/src/solarxr_protocol/rpc/SaveFileRequestT.java @@ -7,7 +7,7 @@ import java.util.*; import com.google.flatbuffers.*; -public class SaveFileResponseT { +public class SaveFileRequestT { private String path; private Boolean canceled; @@ -20,7 +20,7 @@ public class SaveFileResponseT { public void setCanceled(Boolean canceled) { this.canceled = canceled; } - public SaveFileResponseT() { + public SaveFileRequestT() { this.path = null; this.canceled = null; } diff --git a/protocol/kotlin/src/solarxr_protocol/rpc/SaveFileResponse.kt b/protocol/kotlin/src/solarxr_protocol/rpc/SaveFileRequest.kt similarity index 71% rename from protocol/kotlin/src/solarxr_protocol/rpc/SaveFileResponse.kt rename to protocol/kotlin/src/solarxr_protocol/rpc/SaveFileRequest.kt index ee13777c..78782168 100644 --- a/protocol/kotlin/src/solarxr_protocol/rpc/SaveFileResponse.kt +++ b/protocol/kotlin/src/solarxr_protocol/rpc/SaveFileRequest.kt @@ -7,12 +7,12 @@ import kotlin.math.sign import com.google.flatbuffers.* @Suppress("unused") -class SaveFileResponse : Table() { +class SaveFileRequest : Table() { fun __init(_i: Int, _bb: ByteBuffer) { __reset(_i, _bb) } - fun __assign(_i: Int, _bb: ByteBuffer) : SaveFileResponse { + fun __assign(_i: Int, _bb: ByteBuffer) : SaveFileRequest { __init(_i, _bb) return this } @@ -27,7 +27,7 @@ class SaveFileResponse : Table() { val pathAsByteBuffer : ByteBuffer get() = __vector_as_bytebuffer(4, 1) fun pathInByteBuffer(_bb: ByteBuffer) : ByteBuffer = __vector_in_bytebuffer(_bb, 4, 1) /** - * Iff false, the file save wwill be canceled + * Iff false, the file save will be canceled */ val canceled : Boolean? get() { @@ -38,27 +38,27 @@ class SaveFileResponse : Table() { @JvmStatic fun validateVersion() = Constants.FLATBUFFERS_22_10_26() @JvmStatic - fun getRootAsSaveFileResponse(_bb: ByteBuffer): SaveFileResponse = getRootAsSaveFileResponse(_bb, SaveFileResponse()) + fun getRootAsSaveFileRequest(_bb: ByteBuffer): SaveFileRequest = getRootAsSaveFileRequest(_bb, SaveFileRequest()) @JvmStatic - fun getRootAsSaveFileResponse(_bb: ByteBuffer, obj: SaveFileResponse): SaveFileResponse { + fun getRootAsSaveFileRequest(_bb: ByteBuffer, obj: SaveFileRequest): SaveFileRequest { _bb.order(ByteOrder.LITTLE_ENDIAN) return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)) } @JvmStatic - fun createSaveFileResponse(builder: FlatBufferBuilder, pathOffset: Int, canceled: Boolean?) : Int { + fun createSaveFileRequest(builder: FlatBufferBuilder, pathOffset: Int, canceled: Boolean?) : Int { builder.startTable(2) addPath(builder, pathOffset) canceled?.run { addCanceled(builder, canceled) } - return endSaveFileResponse(builder) + return endSaveFileRequest(builder) } @JvmStatic - fun startSaveFileResponse(builder: FlatBufferBuilder) = builder.startTable(2) + fun startSaveFileRequest(builder: FlatBufferBuilder) = builder.startTable(2) @JvmStatic fun addPath(builder: FlatBufferBuilder, path: Int) = builder.addOffset(0, path, 0) @JvmStatic fun addCanceled(builder: FlatBufferBuilder, canceled: Boolean) = builder.addBoolean(1, canceled, false) @JvmStatic - fun endSaveFileResponse(builder: FlatBufferBuilder) : Int { + fun endSaveFileRequest(builder: FlatBufferBuilder) : Int { val o = builder.endTable() return o } diff --git a/protocol/rust/src/generated/mod.rs b/protocol/rust/src/generated/mod.rs index f0dfd324..31459b18 100644 --- a/protocol/rust/src/generated/mod.rs +++ b/protocol/rust/src/generated/mod.rs @@ -278,8 +278,8 @@ pub mod solarxr_protocol { pub use self::clear_mounting_reset_request_generated::*; mod save_file_notification_generated; pub use self::save_file_notification_generated::*; - mod save_file_response_generated; - pub use self::save_file_response_generated::*; + mod save_file_request_generated; + pub use self::save_file_request_generated::*; } // rpc mod message_bundle_generated; pub use self::message_bundle_generated::*; diff --git a/protocol/rust/src/generated/solarxr_protocol/rpc/save_file_response_generated.rs b/protocol/rust/src/generated/solarxr_protocol/rpc/save_file_request_generated.rs similarity index 70% rename from protocol/rust/src/generated/solarxr_protocol/rpc/save_file_response_generated.rs rename to protocol/rust/src/generated/solarxr_protocol/rpc/save_file_request_generated.rs index 37c98c8b..da06fdbe 100644 --- a/protocol/rust/src/generated/solarxr_protocol/rpc/save_file_response_generated.rs +++ b/protocol/rust/src/generated/solarxr_protocol/rpc/save_file_request_generated.rs @@ -9,35 +9,35 @@ use core::mem; use core::cmp::Ordering; use self::flatbuffers::{EndianScalar, Follow}; use super::*; -pub enum SaveFileResponseOffset {} +pub enum SaveFileRequestOffset {} #[derive(Copy, Clone, PartialEq)] -pub struct SaveFileResponse<'a> { +pub struct SaveFileRequest<'a> { pub _tab: flatbuffers::Table<'a>, } -impl<'a> flatbuffers::Follow<'a> for SaveFileResponse<'a> { - type Inner = SaveFileResponse<'a>; +impl<'a> flatbuffers::Follow<'a> for SaveFileRequest<'a> { + type Inner = SaveFileRequest<'a>; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { Self { _tab: flatbuffers::Table::new(buf, loc) } } } -impl<'a> SaveFileResponse<'a> { +impl<'a> SaveFileRequest<'a> { pub const VT_PATH: flatbuffers::VOffsetT = 4; pub const VT_CANCELED: flatbuffers::VOffsetT = 6; #[inline] pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - SaveFileResponse { _tab: table } + SaveFileRequest { _tab: table } } #[allow(unused_mut)] pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>, - args: &'args SaveFileResponseArgs<'args> - ) -> flatbuffers::WIPOffset> { - let mut builder = SaveFileResponseBuilder::new(_fbb); + args: &'args SaveFileRequestArgs<'args> + ) -> flatbuffers::WIPOffset> { + let mut builder = SaveFileRequestBuilder::new(_fbb); if let Some(x) = args.path { builder.add_path(x); } if let Some(x) = args.canceled { builder.add_canceled(x); } builder.finish() @@ -50,19 +50,19 @@ impl<'a> SaveFileResponse<'a> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::>(SaveFileResponse::VT_PATH, None)} + unsafe { self._tab.get::>(SaveFileRequest::VT_PATH, None)} } - /// Iff false, the file save wwill be canceled + /// Iff false, the file save will be canceled #[inline] pub fn canceled(&self) -> Option { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::(SaveFileResponse::VT_CANCELED, None)} + unsafe { self._tab.get::(SaveFileRequest::VT_CANCELED, None)} } } -impl flatbuffers::Verifiable for SaveFileResponse<'_> { +impl flatbuffers::Verifiable for SaveFileRequest<'_> { #[inline] fn run_verifier( v: &mut flatbuffers::Verifier, pos: usize @@ -75,51 +75,51 @@ impl flatbuffers::Verifiable for SaveFileResponse<'_> { Ok(()) } } -pub struct SaveFileResponseArgs<'a> { +pub struct SaveFileRequestArgs<'a> { pub path: Option>, pub canceled: Option, } -impl<'a> Default for SaveFileResponseArgs<'a> { +impl<'a> Default for SaveFileRequestArgs<'a> { #[inline] fn default() -> Self { - SaveFileResponseArgs { + SaveFileRequestArgs { path: None, canceled: None, } } } -pub struct SaveFileResponseBuilder<'a: 'b, 'b> { +pub struct SaveFileRequestBuilder<'a: 'b, 'b> { fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>, start_: flatbuffers::WIPOffset, } -impl<'a: 'b, 'b> SaveFileResponseBuilder<'a, 'b> { +impl<'a: 'b, 'b> SaveFileRequestBuilder<'a, 'b> { #[inline] pub fn add_path(&mut self, path: flatbuffers::WIPOffset<&'b str>) { - self.fbb_.push_slot_always::>(SaveFileResponse::VT_PATH, path); + self.fbb_.push_slot_always::>(SaveFileRequest::VT_PATH, path); } #[inline] pub fn add_canceled(&mut self, canceled: bool) { - self.fbb_.push_slot_always::(SaveFileResponse::VT_CANCELED, canceled); + self.fbb_.push_slot_always::(SaveFileRequest::VT_CANCELED, canceled); } #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> SaveFileResponseBuilder<'a, 'b> { + pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> SaveFileRequestBuilder<'a, 'b> { let start = _fbb.start_table(); - SaveFileResponseBuilder { + SaveFileRequestBuilder { fbb_: _fbb, start_: start, } } #[inline] - pub fn finish(self) -> flatbuffers::WIPOffset> { + pub fn finish(self) -> flatbuffers::WIPOffset> { let o = self.fbb_.end_table(self.start_); flatbuffers::WIPOffset::new(o.value()) } } -impl core::fmt::Debug for SaveFileResponse<'_> { +impl core::fmt::Debug for SaveFileRequest<'_> { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let mut ds = f.debug_struct("SaveFileResponse"); + let mut ds = f.debug_struct("SaveFileRequest"); ds.field("path", &self.path()); ds.field("canceled", &self.canceled()); ds.finish() diff --git a/protocol/typescript/src/all_generated.ts b/protocol/typescript/src/all_generated.ts index 27e1f350..71115f7a 100644 --- a/protocol/typescript/src/all_generated.ts +++ b/protocol/typescript/src/all_generated.ts @@ -85,7 +85,7 @@ export { ResetType } from './solarxr-protocol/rpc/reset-type.js'; export { RpcMessage, unionToRpcMessage, unionListToRpcMessage } from './solarxr-protocol/rpc/rpc-message.js'; export { RpcMessageHeader, RpcMessageHeaderT } from './solarxr-protocol/rpc/rpc-message-header.js'; export { SaveFileNotification, SaveFileNotificationT } from './solarxr-protocol/rpc/save-file-notification.js'; -export { SaveFileResponse, SaveFileResponseT } from './solarxr-protocol/rpc/save-file-response.js'; +export { SaveFileRequest, SaveFileRequestT } from './solarxr-protocol/rpc/save-file-request.js'; export { SerialDevice, SerialDeviceT } from './solarxr-protocol/rpc/serial-device.js'; export { SerialDevicesRequest, SerialDevicesRequestT } from './solarxr-protocol/rpc/serial-devices-request.js'; export { SerialDevicesResponse, SerialDevicesResponseT } from './solarxr-protocol/rpc/serial-devices-response.js'; diff --git a/protocol/typescript/src/solarxr-protocol/rpc/save-file-response.ts b/protocol/typescript/src/solarxr-protocol/rpc/save-file-request.ts similarity index 53% rename from protocol/typescript/src/solarxr-protocol/rpc/save-file-response.ts rename to protocol/typescript/src/solarxr-protocol/rpc/save-file-request.ts index e5a8b9af..37a022bf 100644 --- a/protocol/typescript/src/solarxr-protocol/rpc/save-file-response.ts +++ b/protocol/typescript/src/solarxr-protocol/rpc/save-file-request.ts @@ -4,22 +4,22 @@ import * as flatbuffers from 'flatbuffers'; -export class SaveFileResponse implements flatbuffers.IUnpackableObject { +export class SaveFileRequest implements flatbuffers.IUnpackableObject { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; - __init(i:number, bb:flatbuffers.ByteBuffer):SaveFileResponse { + __init(i:number, bb:flatbuffers.ByteBuffer):SaveFileRequest { this.bb_pos = i; this.bb = bb; return this; } -static getRootAsSaveFileResponse(bb:flatbuffers.ByteBuffer, obj?:SaveFileResponse):SaveFileResponse { - return (obj || new SaveFileResponse()).__init(bb.readInt32(bb.position()) + bb.position(), bb); +static getRootAsSaveFileRequest(bb:flatbuffers.ByteBuffer, obj?:SaveFileRequest):SaveFileRequest { + return (obj || new SaveFileRequest()).__init(bb.readInt32(bb.position()) + bb.position(), bb); } -static getSizePrefixedRootAsSaveFileResponse(bb:flatbuffers.ByteBuffer, obj?:SaveFileResponse):SaveFileResponse { +static getSizePrefixedRootAsSaveFileRequest(bb:flatbuffers.ByteBuffer, obj?:SaveFileRequest):SaveFileRequest { bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new SaveFileResponse()).__init(bb.readInt32(bb.position()) + bb.position(), bb); + return (obj || new SaveFileRequest()).__init(bb.readInt32(bb.position()) + bb.position(), bb); } /** @@ -33,14 +33,14 @@ path(optionalEncoding?:any):string|Uint8Array|null { } /** - * Iff false, the file save wwill be canceled + * Iff false, the file save will be canceled */ canceled():boolean|null { const offset = this.bb!.__offset(this.bb_pos, 6); return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : null; } -static startSaveFileResponse(builder:flatbuffers.Builder) { +static startSaveFileRequest(builder:flatbuffers.Builder) { builder.startObject(2); } @@ -52,34 +52,34 @@ static addCanceled(builder:flatbuffers.Builder, canceled:boolean) { builder.addFieldInt8(1, +canceled, 0); } -static endSaveFileResponse(builder:flatbuffers.Builder):flatbuffers.Offset { +static endSaveFileRequest(builder:flatbuffers.Builder):flatbuffers.Offset { const offset = builder.endObject(); return offset; } -static createSaveFileResponse(builder:flatbuffers.Builder, pathOffset:flatbuffers.Offset, canceled:boolean|null):flatbuffers.Offset { - SaveFileResponse.startSaveFileResponse(builder); - SaveFileResponse.addPath(builder, pathOffset); +static createSaveFileRequest(builder:flatbuffers.Builder, pathOffset:flatbuffers.Offset, canceled:boolean|null):flatbuffers.Offset { + SaveFileRequest.startSaveFileRequest(builder); + SaveFileRequest.addPath(builder, pathOffset); if (canceled !== null) - SaveFileResponse.addCanceled(builder, canceled); - return SaveFileResponse.endSaveFileResponse(builder); + SaveFileRequest.addCanceled(builder, canceled); + return SaveFileRequest.endSaveFileRequest(builder); } -unpack(): SaveFileResponseT { - return new SaveFileResponseT( +unpack(): SaveFileRequestT { + return new SaveFileRequestT( this.path(), this.canceled() ); } -unpackTo(_o: SaveFileResponseT): void { +unpackTo(_o: SaveFileRequestT): void { _o.path = this.path(); _o.canceled = this.canceled(); } } -export class SaveFileResponseT implements flatbuffers.IGeneratedObject { +export class SaveFileRequestT implements flatbuffers.IGeneratedObject { constructor( public path: string|Uint8Array|null = null, public canceled: boolean|null = null @@ -89,7 +89,7 @@ constructor( pack(builder:flatbuffers.Builder): flatbuffers.Offset { const path = (this.path !== null ? builder.createString(this.path!) : 0); - return SaveFileResponse.createSaveFileResponse(builder, + return SaveFileRequest.createSaveFileRequest(builder, path, this.canceled ); diff --git a/schema/rpc.fbs b/schema/rpc.fbs index 0bdd20aa..52672cc7 100644 --- a/schema/rpc.fbs +++ b/schema/rpc.fbs @@ -541,9 +541,9 @@ table SaveFileNotification { expected_filename: string; } -table SaveFileResponse { +table SaveFileRequest { /// Where to save the file, if null, server will choose where to save it path: string; - /// Iff false, the file save wwill be canceled + /// Iff false, the file save will be canceled canceled: bool = null; } From fa9a557085ceedf35ffa39d055ff24ea8a5db189 Mon Sep 17 00:00:00 2001 From: ImUrX Date: Thu, 3 Aug 2023 03:02:25 -0300 Subject: [PATCH 5/5] Forgot to save --- .../generated/all_generated.h | 39 ++++++++++++++++--- .../rpc/SaveFileNotification.java | 18 +++++++-- .../rpc/SaveFileNotificationT.java | 6 +++ .../solarxr_protocol/rpc/SaveFileRequest.java | 31 ++++++++++----- .../rpc/SaveFileRequestT.java | 6 +++ .../rpc/SaveFileNotification.kt | 17 ++++++-- .../solarxr_protocol/rpc/SaveFileRequest.kt | 32 ++++++++++----- .../rpc/save_file_notification_generated.rs | 18 +++++++++ .../rpc/save_file_request_generated.rs | 23 ++++++++++- .../rpc/save-file-notification.ts | 27 ++++++++++--- .../solarxr-protocol/rpc/save-file-request.ts | 32 ++++++++++++--- schema/rpc.fbs | 5 +++ 12 files changed, 210 insertions(+), 44 deletions(-) diff --git a/protocol/cpp/include/solarxr_protocol/generated/all_generated.h b/protocol/cpp/include/solarxr_protocol/generated/all_generated.h index 2a65fb0c..d5ec42b1 100644 --- a/protocol/cpp/include/solarxr_protocol/generated/all_generated.h +++ b/protocol/cpp/include/solarxr_protocol/generated/all_generated.h @@ -8177,7 +8177,8 @@ struct SaveFileNotification FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table VT_MIME_TYPE = 4, VT_FILE_EXTENSION = 6, VT_EXPECTED_DIR = 8, - VT_EXPECTED_FILENAME = 10 + VT_EXPECTED_FILENAME = 10, + VT_ID = 12 }; /// MIME type of file if one exists, use `file_extension` otherwise const flatbuffers::String *mime_type() const { @@ -8195,6 +8196,10 @@ struct SaveFileNotification FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table const flatbuffers::String *expected_filename() const { return GetPointer(VT_EXPECTED_FILENAME); } + /// ID of the SaveFile, needs to be returned by the SaveFileRequest + uint32_t id() const { + return GetField(VT_ID, 0); + } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyOffset(verifier, VT_MIME_TYPE) && @@ -8204,6 +8209,7 @@ struct SaveFileNotification FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table VerifyField(verifier, VT_EXPECTED_DIR, 1) && VerifyOffset(verifier, VT_EXPECTED_FILENAME) && verifier.VerifyString(expected_filename()) && + VerifyField(verifier, VT_ID, 4) && verifier.EndTable(); } }; @@ -8224,6 +8230,9 @@ struct SaveFileNotificationBuilder { void add_expected_filename(flatbuffers::Offset expected_filename) { fbb_.AddOffset(SaveFileNotification::VT_EXPECTED_FILENAME, expected_filename); } + void add_id(uint32_t id) { + fbb_.AddElement(SaveFileNotification::VT_ID, id, 0); + } explicit SaveFileNotificationBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); @@ -8240,8 +8249,10 @@ inline flatbuffers::Offset CreateSaveFileNotification( flatbuffers::Offset mime_type = 0, flatbuffers::Offset file_extension = 0, flatbuffers::Optional expected_dir = flatbuffers::nullopt, - flatbuffers::Offset expected_filename = 0) { + flatbuffers::Offset expected_filename = 0, + uint32_t id = 0) { SaveFileNotificationBuilder builder_(_fbb); + builder_.add_id(id); builder_.add_expected_filename(expected_filename); builder_.add_file_extension(file_extension); builder_.add_mime_type(mime_type); @@ -8254,7 +8265,8 @@ inline flatbuffers::Offset CreateSaveFileNotificationDirec const char *mime_type = nullptr, const char *file_extension = nullptr, flatbuffers::Optional expected_dir = flatbuffers::nullopt, - const char *expected_filename = nullptr) { + const char *expected_filename = nullptr, + uint32_t id = 0) { auto mime_type__ = mime_type ? _fbb.CreateString(mime_type) : 0; auto file_extension__ = file_extension ? _fbb.CreateString(file_extension) : 0; auto expected_filename__ = expected_filename ? _fbb.CreateString(expected_filename) : 0; @@ -8263,15 +8275,22 @@ inline flatbuffers::Offset CreateSaveFileNotificationDirec mime_type__, file_extension__, expected_dir, - expected_filename__); + expected_filename__, + id); } +/// Response of the SaveFileNotification after the user interacts with the file save request struct SaveFileRequest FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef SaveFileRequestBuilder Builder; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { - VT_PATH = 4, - VT_CANCELED = 6 + VT_ID = 4, + VT_PATH = 6, + VT_CANCELED = 8 }; + /// ID of the SaveFile, given by SaveFileNotification + uint32_t id() const { + return GetField(VT_ID, 0); + } /// Where to save the file, if null, server will choose where to save it const flatbuffers::String *path() const { return GetPointer(VT_PATH); @@ -8282,6 +8301,7 @@ struct SaveFileRequest FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && + VerifyField(verifier, VT_ID, 4) && VerifyOffset(verifier, VT_PATH) && verifier.VerifyString(path()) && VerifyField(verifier, VT_CANCELED, 1) && @@ -8293,6 +8313,9 @@ struct SaveFileRequestBuilder { typedef SaveFileRequest Table; flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; + void add_id(uint32_t id) { + fbb_.AddElement(SaveFileRequest::VT_ID, id, 0); + } void add_path(flatbuffers::Offset path) { fbb_.AddOffset(SaveFileRequest::VT_PATH, path); } @@ -8312,21 +8335,25 @@ struct SaveFileRequestBuilder { inline flatbuffers::Offset CreateSaveFileRequest( flatbuffers::FlatBufferBuilder &_fbb, + uint32_t id = 0, flatbuffers::Offset path = 0, flatbuffers::Optional canceled = flatbuffers::nullopt) { SaveFileRequestBuilder builder_(_fbb); builder_.add_path(path); + builder_.add_id(id); if(canceled) { builder_.add_canceled(*canceled); } return builder_.Finish(); } inline flatbuffers::Offset CreateSaveFileRequestDirect( flatbuffers::FlatBufferBuilder &_fbb, + uint32_t id = 0, const char *path = nullptr, flatbuffers::Optional canceled = flatbuffers::nullopt) { auto path__ = path ? _fbb.CreateString(path) : 0; return solarxr_protocol::rpc::CreateSaveFileRequest( _fbb, + id, path__, canceled); } diff --git a/protocol/java/src/solarxr_protocol/rpc/SaveFileNotification.java b/protocol/java/src/solarxr_protocol/rpc/SaveFileNotification.java index 4a4c7774..76ec8bd9 100644 --- a/protocol/java/src/solarxr_protocol/rpc/SaveFileNotification.java +++ b/protocol/java/src/solarxr_protocol/rpc/SaveFileNotification.java @@ -41,13 +41,19 @@ public final class SaveFileNotification extends Table { public String expectedFilename() { int o = __offset(10); return o != 0 ? __string(o + bb_pos) : null; } public ByteBuffer expectedFilenameAsByteBuffer() { return __vector_as_bytebuffer(10, 1); } public ByteBuffer expectedFilenameInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 10, 1); } + /** + * ID of the SaveFile, needs to be returned by the SaveFileRequest + */ + public long id() { int o = __offset(12); return o != 0 ? (long)bb.getInt(o + bb_pos) & 0xFFFFFFFFL : 0L; } public static int createSaveFileNotification(FlatBufferBuilder builder, int mimeTypeOffset, int fileExtensionOffset, int expectedDir, - int expectedFilenameOffset) { - builder.startTable(4); + int expectedFilenameOffset, + long id) { + builder.startTable(5); + SaveFileNotification.addId(builder, id); SaveFileNotification.addExpectedFilename(builder, expectedFilenameOffset); SaveFileNotification.addFileExtension(builder, fileExtensionOffset); SaveFileNotification.addMimeType(builder, mimeTypeOffset); @@ -55,11 +61,12 @@ public static int createSaveFileNotification(FlatBufferBuilder builder, return SaveFileNotification.endSaveFileNotification(builder); } - public static void startSaveFileNotification(FlatBufferBuilder builder) { builder.startTable(4); } + public static void startSaveFileNotification(FlatBufferBuilder builder) { builder.startTable(5); } public static void addMimeType(FlatBufferBuilder builder, int mimeTypeOffset) { builder.addOffset(0, mimeTypeOffset, 0); } public static void addFileExtension(FlatBufferBuilder builder, int fileExtensionOffset) { builder.addOffset(1, fileExtensionOffset, 0); } public static void addExpectedDir(FlatBufferBuilder builder, int expectedDir) { builder.addByte(2, (byte) expectedDir, (byte) 0); } public static void addExpectedFilename(FlatBufferBuilder builder, int expectedFilenameOffset) { builder.addOffset(3, expectedFilenameOffset, 0); } + public static void addId(FlatBufferBuilder builder, long id) { builder.addInt(4, (int) id, (int) 0L); } public static int endSaveFileNotification(FlatBufferBuilder builder) { int o = builder.endTable(); return o; @@ -85,6 +92,8 @@ public void unpackTo(SaveFileNotificationT _o) { _o.setExpectedDir(_oExpectedDir); String _oExpectedFilename = expectedFilename(); _o.setExpectedFilename(_oExpectedFilename); + long _oId = id(); + _o.setId(_oId); } public static int pack(FlatBufferBuilder builder, SaveFileNotificationT _o) { if (_o == null) return 0; @@ -96,7 +105,8 @@ public static int pack(FlatBufferBuilder builder, SaveFileNotificationT _o) { _mimeType, _fileExtension, _o.getExpectedDir(), - _expectedFilename); + _expectedFilename, + _o.getId()); } } diff --git a/protocol/java/src/solarxr_protocol/rpc/SaveFileNotificationT.java b/protocol/java/src/solarxr_protocol/rpc/SaveFileNotificationT.java index af2d75b8..d08ce5f0 100644 --- a/protocol/java/src/solarxr_protocol/rpc/SaveFileNotificationT.java +++ b/protocol/java/src/solarxr_protocol/rpc/SaveFileNotificationT.java @@ -12,6 +12,7 @@ public class SaveFileNotificationT { private String fileExtension; private Integer expectedDir; private String expectedFilename; + private long id; public String getMimeType() { return mimeType; } @@ -29,12 +30,17 @@ public class SaveFileNotificationT { public void setExpectedFilename(String expectedFilename) { this.expectedFilename = expectedFilename; } + public long getId() { return id; } + + public void setId(long id) { this.id = id; } + public SaveFileNotificationT() { this.mimeType = null; this.fileExtension = null; this.expectedDir = null; this.expectedFilename = null; + this.id = 0L; } } diff --git a/protocol/java/src/solarxr_protocol/rpc/SaveFileRequest.java b/protocol/java/src/solarxr_protocol/rpc/SaveFileRequest.java index e14262f9..bc6ac8b2 100644 --- a/protocol/java/src/solarxr_protocol/rpc/SaveFileRequest.java +++ b/protocol/java/src/solarxr_protocol/rpc/SaveFileRequest.java @@ -7,6 +7,9 @@ import java.util.*; import com.google.flatbuffers.*; +/** + * Response of the SaveFileNotification after the user interacts with the file save request + */ @SuppressWarnings("unused") public final class SaveFileRequest extends Table { public static void ValidateVersion() { Constants.FLATBUFFERS_22_10_26(); } @@ -15,30 +18,37 @@ public final class SaveFileRequest extends Table { public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); } public SaveFileRequest __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; } + /** + * ID of the SaveFile, given by SaveFileNotification + */ + public long id() { int o = __offset(4); return o != 0 ? (long)bb.getInt(o + bb_pos) & 0xFFFFFFFFL : 0L; } /** * Where to save the file, if null, server will choose where to save it */ - public String path() { int o = __offset(4); return o != 0 ? __string(o + bb_pos) : null; } - public ByteBuffer pathAsByteBuffer() { return __vector_as_bytebuffer(4, 1); } - public ByteBuffer pathInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 4, 1); } + public String path() { int o = __offset(6); return o != 0 ? __string(o + bb_pos) : null; } + public ByteBuffer pathAsByteBuffer() { return __vector_as_bytebuffer(6, 1); } + public ByteBuffer pathInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 6, 1); } /** * Iff false, the file save will be canceled */ - public boolean hasCanceled() { return 0 != __offset(6); } - public boolean canceled() { int o = __offset(6); return o != 0 ? 0!=bb.get(o + bb_pos) : false; } + public boolean hasCanceled() { return 0 != __offset(8); } + public boolean canceled() { int o = __offset(8); return o != 0 ? 0!=bb.get(o + bb_pos) : false; } public static int createSaveFileRequest(FlatBufferBuilder builder, + long id, int pathOffset, boolean canceled) { - builder.startTable(2); + builder.startTable(3); SaveFileRequest.addPath(builder, pathOffset); + SaveFileRequest.addId(builder, id); SaveFileRequest.addCanceled(builder, canceled); return SaveFileRequest.endSaveFileRequest(builder); } - public static void startSaveFileRequest(FlatBufferBuilder builder) { builder.startTable(2); } - public static void addPath(FlatBufferBuilder builder, int pathOffset) { builder.addOffset(0, pathOffset, 0); } - public static void addCanceled(FlatBufferBuilder builder, boolean canceled) { builder.addBoolean(1, canceled, false); } + public static void startSaveFileRequest(FlatBufferBuilder builder) { builder.startTable(3); } + public static void addId(FlatBufferBuilder builder, long id) { builder.addInt(0, (int) id, (int) 0L); } + public static void addPath(FlatBufferBuilder builder, int pathOffset) { builder.addOffset(1, pathOffset, 0); } + public static void addCanceled(FlatBufferBuilder builder, boolean canceled) { builder.addBoolean(2, canceled, false); } public static int endSaveFileRequest(FlatBufferBuilder builder) { int o = builder.endTable(); return o; @@ -56,6 +66,8 @@ public SaveFileRequestT unpack() { return _o; } public void unpackTo(SaveFileRequestT _o) { + long _oId = id(); + _o.setId(_oId); String _oPath = path(); _o.setPath(_oPath); Boolean _oCanceled = hasCanceled() ? canceled() : null; @@ -66,6 +78,7 @@ public static int pack(FlatBufferBuilder builder, SaveFileRequestT _o) { int _path = _o.getPath() == null ? 0 : builder.createString(_o.getPath()); return createSaveFileRequest( builder, + _o.getId(), _path, _o.getCanceled()); } diff --git a/protocol/java/src/solarxr_protocol/rpc/SaveFileRequestT.java b/protocol/java/src/solarxr_protocol/rpc/SaveFileRequestT.java index 0a790156..a8466093 100644 --- a/protocol/java/src/solarxr_protocol/rpc/SaveFileRequestT.java +++ b/protocol/java/src/solarxr_protocol/rpc/SaveFileRequestT.java @@ -8,9 +8,14 @@ import com.google.flatbuffers.*; public class SaveFileRequestT { + private long id; private String path; private Boolean canceled; + public long getId() { return id; } + + public void setId(long id) { this.id = id; } + public String getPath() { return path; } public void setPath(String path) { this.path = path; } @@ -21,6 +26,7 @@ public class SaveFileRequestT { public SaveFileRequestT() { + this.id = 0L; this.path = null; this.canceled = null; } diff --git a/protocol/kotlin/src/solarxr_protocol/rpc/SaveFileNotification.kt b/protocol/kotlin/src/solarxr_protocol/rpc/SaveFileNotification.kt index ab49439b..abd05b0e 100644 --- a/protocol/kotlin/src/solarxr_protocol/rpc/SaveFileNotification.kt +++ b/protocol/kotlin/src/solarxr_protocol/rpc/SaveFileNotification.kt @@ -57,6 +57,14 @@ class SaveFileNotification : Table() { } val expectedFilenameAsByteBuffer : ByteBuffer get() = __vector_as_bytebuffer(10, 1) fun expectedFilenameInByteBuffer(_bb: ByteBuffer) : ByteBuffer = __vector_in_bytebuffer(_bb, 10, 1) + /** + * ID of the SaveFile, needs to be returned by the SaveFileRequest + */ + val id : UInt + get() { + val o = __offset(12) + return if(o != 0) bb.getInt(o + bb_pos).toUInt() else 0u + } companion object { @JvmStatic fun validateVersion() = Constants.FLATBUFFERS_22_10_26() @@ -68,8 +76,9 @@ class SaveFileNotification : Table() { return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)) } @JvmStatic - fun createSaveFileNotification(builder: FlatBufferBuilder, mimeTypeOffset: Int, fileExtensionOffset: Int, expectedDir: UByte?, expectedFilenameOffset: Int) : Int { - builder.startTable(4) + fun createSaveFileNotification(builder: FlatBufferBuilder, mimeTypeOffset: Int, fileExtensionOffset: Int, expectedDir: UByte?, expectedFilenameOffset: Int, id: UInt) : Int { + builder.startTable(5) + addId(builder, id) addExpectedFilename(builder, expectedFilenameOffset) addFileExtension(builder, fileExtensionOffset) addMimeType(builder, mimeTypeOffset) @@ -77,7 +86,7 @@ class SaveFileNotification : Table() { return endSaveFileNotification(builder) } @JvmStatic - fun startSaveFileNotification(builder: FlatBufferBuilder) = builder.startTable(4) + fun startSaveFileNotification(builder: FlatBufferBuilder) = builder.startTable(5) @JvmStatic fun addMimeType(builder: FlatBufferBuilder, mimeType: Int) = builder.addOffset(0, mimeType, 0) @JvmStatic @@ -87,6 +96,8 @@ class SaveFileNotification : Table() { @JvmStatic fun addExpectedFilename(builder: FlatBufferBuilder, expectedFilename: Int) = builder.addOffset(3, expectedFilename, 0) @JvmStatic + fun addId(builder: FlatBufferBuilder, id: UInt) = builder.addInt(4, id.toInt(), 0) + @JvmStatic fun endSaveFileNotification(builder: FlatBufferBuilder) : Int { val o = builder.endTable() return o diff --git a/protocol/kotlin/src/solarxr_protocol/rpc/SaveFileRequest.kt b/protocol/kotlin/src/solarxr_protocol/rpc/SaveFileRequest.kt index 78782168..2c2bed2a 100644 --- a/protocol/kotlin/src/solarxr_protocol/rpc/SaveFileRequest.kt +++ b/protocol/kotlin/src/solarxr_protocol/rpc/SaveFileRequest.kt @@ -6,6 +6,9 @@ import java.nio.* import kotlin.math.sign import com.google.flatbuffers.* +/** + * Response of the SaveFileNotification after the user interacts with the file save request + */ @Suppress("unused") class SaveFileRequest : Table() { @@ -16,22 +19,30 @@ class SaveFileRequest : Table() { __init(_i, _bb) return this } + /** + * ID of the SaveFile, given by SaveFileNotification + */ + val id : UInt + get() { + val o = __offset(4) + return if(o != 0) bb.getInt(o + bb_pos).toUInt() else 0u + } /** * Where to save the file, if null, server will choose where to save it */ val path : String? get() { - val o = __offset(4) + val o = __offset(6) return if (o != 0) __string(o + bb_pos) else null } - val pathAsByteBuffer : ByteBuffer get() = __vector_as_bytebuffer(4, 1) - fun pathInByteBuffer(_bb: ByteBuffer) : ByteBuffer = __vector_in_bytebuffer(_bb, 4, 1) + val pathAsByteBuffer : ByteBuffer get() = __vector_as_bytebuffer(6, 1) + fun pathInByteBuffer(_bb: ByteBuffer) : ByteBuffer = __vector_in_bytebuffer(_bb, 6, 1) /** * Iff false, the file save will be canceled */ val canceled : Boolean? get() { - val o = __offset(6) + val o = __offset(8) return if(o != 0) 0.toByte() != bb.get(o + bb_pos) else null } companion object { @@ -45,18 +56,21 @@ class SaveFileRequest : Table() { return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)) } @JvmStatic - fun createSaveFileRequest(builder: FlatBufferBuilder, pathOffset: Int, canceled: Boolean?) : Int { - builder.startTable(2) + fun createSaveFileRequest(builder: FlatBufferBuilder, id: UInt, pathOffset: Int, canceled: Boolean?) : Int { + builder.startTable(3) addPath(builder, pathOffset) + addId(builder, id) canceled?.run { addCanceled(builder, canceled) } return endSaveFileRequest(builder) } @JvmStatic - fun startSaveFileRequest(builder: FlatBufferBuilder) = builder.startTable(2) + fun startSaveFileRequest(builder: FlatBufferBuilder) = builder.startTable(3) + @JvmStatic + fun addId(builder: FlatBufferBuilder, id: UInt) = builder.addInt(0, id.toInt(), 0) @JvmStatic - fun addPath(builder: FlatBufferBuilder, path: Int) = builder.addOffset(0, path, 0) + fun addPath(builder: FlatBufferBuilder, path: Int) = builder.addOffset(1, path, 0) @JvmStatic - fun addCanceled(builder: FlatBufferBuilder, canceled: Boolean) = builder.addBoolean(1, canceled, false) + fun addCanceled(builder: FlatBufferBuilder, canceled: Boolean) = builder.addBoolean(2, canceled, false) @JvmStatic fun endSaveFileRequest(builder: FlatBufferBuilder) : Int { val o = builder.endTable() diff --git a/protocol/rust/src/generated/solarxr_protocol/rpc/save_file_notification_generated.rs b/protocol/rust/src/generated/solarxr_protocol/rpc/save_file_notification_generated.rs index 0faf4189..f249337f 100644 --- a/protocol/rust/src/generated/solarxr_protocol/rpc/save_file_notification_generated.rs +++ b/protocol/rust/src/generated/solarxr_protocol/rpc/save_file_notification_generated.rs @@ -30,6 +30,7 @@ impl<'a> SaveFileNotification<'a> { pub const VT_FILE_EXTENSION: flatbuffers::VOffsetT = 6; pub const VT_EXPECTED_DIR: flatbuffers::VOffsetT = 8; pub const VT_EXPECTED_FILENAME: flatbuffers::VOffsetT = 10; + pub const VT_ID: flatbuffers::VOffsetT = 12; #[inline] pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { @@ -41,6 +42,7 @@ impl<'a> SaveFileNotification<'a> { args: &'args SaveFileNotificationArgs<'args> ) -> flatbuffers::WIPOffset> { let mut builder = SaveFileNotificationBuilder::new(_fbb); + builder.add_id(args.id); if let Some(x) = args.expected_filename { builder.add_expected_filename(x); } if let Some(x) = args.file_extension { builder.add_file_extension(x); } if let Some(x) = args.mime_type { builder.add_mime_type(x); } @@ -81,6 +83,14 @@ impl<'a> SaveFileNotification<'a> { // which contains a valid value in this slot unsafe { self._tab.get::>(SaveFileNotification::VT_EXPECTED_FILENAME, None)} } + /// ID of the SaveFile, needs to be returned by the SaveFileRequest + #[inline] + pub fn id(&self) -> u32 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(SaveFileNotification::VT_ID, Some(0)).unwrap()} + } } impl flatbuffers::Verifiable for SaveFileNotification<'_> { @@ -94,6 +104,7 @@ impl flatbuffers::Verifiable for SaveFileNotification<'_> { .visit_field::>("file_extension", Self::VT_FILE_EXTENSION, false)? .visit_field::("expected_dir", Self::VT_EXPECTED_DIR, false)? .visit_field::>("expected_filename", Self::VT_EXPECTED_FILENAME, false)? + .visit_field::("id", Self::VT_ID, false)? .finish(); Ok(()) } @@ -103,6 +114,7 @@ pub struct SaveFileNotificationArgs<'a> { pub file_extension: Option>, pub expected_dir: Option, pub expected_filename: Option>, + pub id: u32, } impl<'a> Default for SaveFileNotificationArgs<'a> { #[inline] @@ -112,6 +124,7 @@ impl<'a> Default for SaveFileNotificationArgs<'a> { file_extension: None, expected_dir: None, expected_filename: None, + id: 0, } } } @@ -138,6 +151,10 @@ impl<'a: 'b, 'b> SaveFileNotificationBuilder<'a, 'b> { self.fbb_.push_slot_always::>(SaveFileNotification::VT_EXPECTED_FILENAME, expected_filename); } #[inline] + pub fn add_id(&mut self, id: u32) { + self.fbb_.push_slot::(SaveFileNotification::VT_ID, id, 0); + } + #[inline] pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> SaveFileNotificationBuilder<'a, 'b> { let start = _fbb.start_table(); SaveFileNotificationBuilder { @@ -159,6 +176,7 @@ impl core::fmt::Debug for SaveFileNotification<'_> { ds.field("file_extension", &self.file_extension()); ds.field("expected_dir", &self.expected_dir()); ds.field("expected_filename", &self.expected_filename()); + ds.field("id", &self.id()); ds.finish() } } diff --git a/protocol/rust/src/generated/solarxr_protocol/rpc/save_file_request_generated.rs b/protocol/rust/src/generated/solarxr_protocol/rpc/save_file_request_generated.rs index da06fdbe..2b308921 100644 --- a/protocol/rust/src/generated/solarxr_protocol/rpc/save_file_request_generated.rs +++ b/protocol/rust/src/generated/solarxr_protocol/rpc/save_file_request_generated.rs @@ -12,6 +12,7 @@ use super::*; pub enum SaveFileRequestOffset {} #[derive(Copy, Clone, PartialEq)] +/// Response of the SaveFileNotification after the user interacts with the file save request pub struct SaveFileRequest<'a> { pub _tab: flatbuffers::Table<'a>, } @@ -25,8 +26,9 @@ impl<'a> flatbuffers::Follow<'a> for SaveFileRequest<'a> { } impl<'a> SaveFileRequest<'a> { - pub const VT_PATH: flatbuffers::VOffsetT = 4; - pub const VT_CANCELED: flatbuffers::VOffsetT = 6; + pub const VT_ID: flatbuffers::VOffsetT = 4; + pub const VT_PATH: flatbuffers::VOffsetT = 6; + pub const VT_CANCELED: flatbuffers::VOffsetT = 8; #[inline] pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { @@ -39,11 +41,20 @@ impl<'a> SaveFileRequest<'a> { ) -> flatbuffers::WIPOffset> { let mut builder = SaveFileRequestBuilder::new(_fbb); if let Some(x) = args.path { builder.add_path(x); } + builder.add_id(args.id); if let Some(x) = args.canceled { builder.add_canceled(x); } builder.finish() } + /// ID of the SaveFile, given by SaveFileNotification + #[inline] + pub fn id(&self) -> u32 { + // Safety: + // Created from valid Table for this object + // which contains a valid value in this slot + unsafe { self._tab.get::(SaveFileRequest::VT_ID, Some(0)).unwrap()} + } /// Where to save the file, if null, server will choose where to save it #[inline] pub fn path(&self) -> Option<&'a str> { @@ -69,6 +80,7 @@ impl flatbuffers::Verifiable for SaveFileRequest<'_> { ) -> Result<(), flatbuffers::InvalidFlatbuffer> { use self::flatbuffers::Verifiable; v.visit_table(pos)? + .visit_field::("id", Self::VT_ID, false)? .visit_field::>("path", Self::VT_PATH, false)? .visit_field::("canceled", Self::VT_CANCELED, false)? .finish(); @@ -76,6 +88,7 @@ impl flatbuffers::Verifiable for SaveFileRequest<'_> { } } pub struct SaveFileRequestArgs<'a> { + pub id: u32, pub path: Option>, pub canceled: Option, } @@ -83,6 +96,7 @@ impl<'a> Default for SaveFileRequestArgs<'a> { #[inline] fn default() -> Self { SaveFileRequestArgs { + id: 0, path: None, canceled: None, } @@ -94,6 +108,10 @@ pub struct SaveFileRequestBuilder<'a: 'b, 'b> { start_: flatbuffers::WIPOffset, } impl<'a: 'b, 'b> SaveFileRequestBuilder<'a, 'b> { + #[inline] + pub fn add_id(&mut self, id: u32) { + self.fbb_.push_slot::(SaveFileRequest::VT_ID, id, 0); + } #[inline] pub fn add_path(&mut self, path: flatbuffers::WIPOffset<&'b str>) { self.fbb_.push_slot_always::>(SaveFileRequest::VT_PATH, path); @@ -120,6 +138,7 @@ impl<'a: 'b, 'b> SaveFileRequestBuilder<'a, 'b> { impl core::fmt::Debug for SaveFileRequest<'_> { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { let mut ds = f.debug_struct("SaveFileRequest"); + ds.field("id", &self.id()); ds.field("path", &self.path()); ds.field("canceled", &self.canceled()); ds.finish() diff --git a/protocol/typescript/src/solarxr-protocol/rpc/save-file-notification.ts b/protocol/typescript/src/solarxr-protocol/rpc/save-file-notification.ts index 0e63c5f2..fee92d9d 100644 --- a/protocol/typescript/src/solarxr-protocol/rpc/save-file-notification.ts +++ b/protocol/typescript/src/solarxr-protocol/rpc/save-file-notification.ts @@ -64,8 +64,16 @@ expectedFilename(optionalEncoding?:any):string|Uint8Array|null { return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; } +/** + * ID of the SaveFile, needs to be returned by the SaveFileRequest + */ +id():number { + const offset = this.bb!.__offset(this.bb_pos, 12); + return offset ? this.bb!.readUint32(this.bb_pos + offset) : 0; +} + static startSaveFileNotification(builder:flatbuffers.Builder) { - builder.startObject(4); + builder.startObject(5); } static addMimeType(builder:flatbuffers.Builder, mimeTypeOffset:flatbuffers.Offset) { @@ -84,18 +92,23 @@ static addExpectedFilename(builder:flatbuffers.Builder, expectedFilenameOffset:f builder.addFieldOffset(3, expectedFilenameOffset, 0); } +static addId(builder:flatbuffers.Builder, id:number) { + builder.addFieldInt32(4, id, 0); +} + static endSaveFileNotification(builder:flatbuffers.Builder):flatbuffers.Offset { const offset = builder.endObject(); return offset; } -static createSaveFileNotification(builder:flatbuffers.Builder, mimeTypeOffset:flatbuffers.Offset, fileExtensionOffset:flatbuffers.Offset, expectedDir:ComputerDirectory|null, expectedFilenameOffset:flatbuffers.Offset):flatbuffers.Offset { +static createSaveFileNotification(builder:flatbuffers.Builder, mimeTypeOffset:flatbuffers.Offset, fileExtensionOffset:flatbuffers.Offset, expectedDir:ComputerDirectory|null, expectedFilenameOffset:flatbuffers.Offset, id:number):flatbuffers.Offset { SaveFileNotification.startSaveFileNotification(builder); SaveFileNotification.addMimeType(builder, mimeTypeOffset); SaveFileNotification.addFileExtension(builder, fileExtensionOffset); if (expectedDir !== null) SaveFileNotification.addExpectedDir(builder, expectedDir); SaveFileNotification.addExpectedFilename(builder, expectedFilenameOffset); + SaveFileNotification.addId(builder, id); return SaveFileNotification.endSaveFileNotification(builder); } @@ -104,7 +117,8 @@ unpack(): SaveFileNotificationT { this.mimeType(), this.fileExtension(), this.expectedDir(), - this.expectedFilename() + this.expectedFilename(), + this.id() ); } @@ -114,6 +128,7 @@ unpackTo(_o: SaveFileNotificationT): void { _o.fileExtension = this.fileExtension(); _o.expectedDir = this.expectedDir(); _o.expectedFilename = this.expectedFilename(); + _o.id = this.id(); } } @@ -122,7 +137,8 @@ constructor( public mimeType: string|Uint8Array|null = null, public fileExtension: string|Uint8Array|null = null, public expectedDir: ComputerDirectory|null = null, - public expectedFilename: string|Uint8Array|null = null + public expectedFilename: string|Uint8Array|null = null, + public id: number = 0 ){} @@ -135,7 +151,8 @@ pack(builder:flatbuffers.Builder): flatbuffers.Offset { mimeType, fileExtension, this.expectedDir, - expectedFilename + expectedFilename, + this.id ); } } diff --git a/protocol/typescript/src/solarxr-protocol/rpc/save-file-request.ts b/protocol/typescript/src/solarxr-protocol/rpc/save-file-request.ts index 37a022bf..665c5535 100644 --- a/protocol/typescript/src/solarxr-protocol/rpc/save-file-request.ts +++ b/protocol/typescript/src/solarxr-protocol/rpc/save-file-request.ts @@ -4,6 +4,9 @@ import * as flatbuffers from 'flatbuffers'; +/** + * Response of the SaveFileNotification after the user interacts with the file save request + */ export class SaveFileRequest implements flatbuffers.IUnpackableObject { bb: flatbuffers.ByteBuffer|null = null; bb_pos = 0; @@ -22,13 +25,21 @@ static getSizePrefixedRootAsSaveFileRequest(bb:flatbuffers.ByteBuffer, obj?:Save return (obj || new SaveFileRequest()).__init(bb.readInt32(bb.position()) + bb.position(), bb); } +/** + * ID of the SaveFile, given by SaveFileNotification + */ +id():number { + const offset = this.bb!.__offset(this.bb_pos, 4); + return offset ? this.bb!.readUint32(this.bb_pos + offset) : 0; +} + /** * Where to save the file, if null, server will choose where to save it */ path():string|null path(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null path(optionalEncoding?:any):string|Uint8Array|null { - const offset = this.bb!.__offset(this.bb_pos, 4); + const offset = this.bb!.__offset(this.bb_pos, 6); return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; } @@ -36,20 +47,24 @@ path(optionalEncoding?:any):string|Uint8Array|null { * Iff false, the file save will be canceled */ canceled():boolean|null { - const offset = this.bb!.__offset(this.bb_pos, 6); + const offset = this.bb!.__offset(this.bb_pos, 8); return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : null; } static startSaveFileRequest(builder:flatbuffers.Builder) { - builder.startObject(2); + builder.startObject(3); +} + +static addId(builder:flatbuffers.Builder, id:number) { + builder.addFieldInt32(0, id, 0); } static addPath(builder:flatbuffers.Builder, pathOffset:flatbuffers.Offset) { - builder.addFieldOffset(0, pathOffset, 0); + builder.addFieldOffset(1, pathOffset, 0); } static addCanceled(builder:flatbuffers.Builder, canceled:boolean) { - builder.addFieldInt8(1, +canceled, 0); + builder.addFieldInt8(2, +canceled, 0); } static endSaveFileRequest(builder:flatbuffers.Builder):flatbuffers.Offset { @@ -57,8 +72,9 @@ static endSaveFileRequest(builder:flatbuffers.Builder):flatbuffers.Offset { return offset; } -static createSaveFileRequest(builder:flatbuffers.Builder, pathOffset:flatbuffers.Offset, canceled:boolean|null):flatbuffers.Offset { +static createSaveFileRequest(builder:flatbuffers.Builder, id:number, pathOffset:flatbuffers.Offset, canceled:boolean|null):flatbuffers.Offset { SaveFileRequest.startSaveFileRequest(builder); + SaveFileRequest.addId(builder, id); SaveFileRequest.addPath(builder, pathOffset); if (canceled !== null) SaveFileRequest.addCanceled(builder, canceled); @@ -67,6 +83,7 @@ static createSaveFileRequest(builder:flatbuffers.Builder, pathOffset:flatbuffers unpack(): SaveFileRequestT { return new SaveFileRequestT( + this.id(), this.path(), this.canceled() ); @@ -74,6 +91,7 @@ unpack(): SaveFileRequestT { unpackTo(_o: SaveFileRequestT): void { + _o.id = this.id(); _o.path = this.path(); _o.canceled = this.canceled(); } @@ -81,6 +99,7 @@ unpackTo(_o: SaveFileRequestT): void { export class SaveFileRequestT implements flatbuffers.IGeneratedObject { constructor( + public id: number = 0, public path: string|Uint8Array|null = null, public canceled: boolean|null = null ){} @@ -90,6 +109,7 @@ pack(builder:flatbuffers.Builder): flatbuffers.Offset { const path = (this.path !== null ? builder.createString(this.path!) : 0); return SaveFileRequest.createSaveFileRequest(builder, + this.id, path, this.canceled ); diff --git a/schema/rpc.fbs b/schema/rpc.fbs index 52672cc7..59549d64 100644 --- a/schema/rpc.fbs +++ b/schema/rpc.fbs @@ -539,9 +539,14 @@ table SaveFileNotification { expected_dir: ComputerDirectory = null; /// Recommended filename expected_filename: string; + /// ID of the SaveFile, needs to be returned by the SaveFileRequest + id: uint32; } +/// Response of the SaveFileNotification after the user interacts with the file save request table SaveFileRequest { + /// ID of the SaveFile, given by SaveFileNotification + id: uint32; /// Where to save the file, if null, server will choose where to save it path: string; /// Iff false, the file save will be canceled