[yunq] Add codegen for clients and servers (untested).
This commit is contained in:
parent
963cc0b4fa
commit
71e3521b87
12 changed files with 472 additions and 75 deletions
|
|
@ -1,3 +1,4 @@
|
|||
// Generated file -- DO NOT MODIFY.
|
||||
#include "example.yunq.h"
|
||||
|
||||
namespace {
|
||||
|
|
@ -26,86 +27,148 @@ void WriteHeader(glcr::ByteBuffer& bytes, uint64_t offset, uint32_t core_size, u
|
|||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
|
||||
|
||||
|
||||
void OpenFileRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
||||
CheckHeader(bytes);
|
||||
|
||||
|
||||
|
||||
auto {field.name}_pointer = bytes.At<ExtPointer>(offset + header_size + (8 * {loop.index}));
|
||||
// Parse path.
|
||||
auto path_pointer = bytes.At<ExtPointer>(offset + header_size + (8 * 0));
|
||||
|
||||
set_path(bytes.StringAt(offset + path_pointer.offset, path_pointer.length));
|
||||
|
||||
|
||||
|
||||
set_options(bytes.At<uint64_t>(offset + header_size + (8 * 2)));
|
||||
|
||||
|
||||
// Parse options.
|
||||
set_options(bytes.At<uint64_t>(offset + header_size + (8 * 1)));
|
||||
}
|
||||
|
||||
void {message.name}::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
|
||||
void OpenFileRequest::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
|
||||
CheckHeader(bytes);
|
||||
|
||||
|
||||
|
||||
auto {field.name}_pointer = bytes.At<ExtPointer>(offset + header_size + (8 * {loop.index}));
|
||||
// Parse path.
|
||||
auto path_pointer = bytes.At<ExtPointer>(offset + header_size + (8 * 0));
|
||||
|
||||
set_path(bytes.StringAt(offset + path_pointer.offset, path_pointer.length));
|
||||
|
||||
|
||||
|
||||
set_options(bytes.At<uint64_t>(offset + header_size + (8 * 2)));
|
||||
|
||||
|
||||
// Parse options.
|
||||
set_options(bytes.At<uint64_t>(offset + header_size + (8 * 1)));
|
||||
}
|
||||
|
||||
uint64_t OpenFileRequest::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) {
|
||||
uint32_t next_extension = header_size + 8 * 2;
|
||||
const uint32_t core_size = next_extension;
|
||||
// Write path.
|
||||
ExtPointer path_ptr{
|
||||
.offset = next_extension,
|
||||
// FIXME: Check downcast of str length.
|
||||
.length = (uint32_t)path().length(),
|
||||
};
|
||||
|
||||
bytes.WriteStringAt(offset + next_extension, path());
|
||||
next_extension += path_ptr.length;
|
||||
|
||||
bytes.WriteAt<ExtPointer>(offset + header_size + (8 * 0), path_ptr);
|
||||
// Write options.
|
||||
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 1), options());
|
||||
|
||||
// The next extension pointer is the length of the message.
|
||||
WriteHeader(bytes, offset, core_size, next_extension);
|
||||
|
||||
return next_extension;
|
||||
}
|
||||
|
||||
uint64_t OpenFileRequest::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset, glcr::CapBuffer& caps) {
|
||||
uint32_t next_extension = header_size + 8 * 2;
|
||||
const uint32_t core_size = next_extension;
|
||||
uint64_t next_cap = 0;
|
||||
// Write path.
|
||||
ExtPointer path_ptr{
|
||||
.offset = next_extension,
|
||||
// FIXME: Check downcast of str length.
|
||||
.length = (uint32_t)path().length(),
|
||||
};
|
||||
|
||||
bytes.WriteStringAt(offset + next_extension, path());
|
||||
next_extension += path_ptr.length;
|
||||
|
||||
bytes.WriteAt<ExtPointer>(offset + header_size + (8 * 0), path_ptr);
|
||||
// Write options.
|
||||
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 1), options());
|
||||
|
||||
// The next extension pointer is the length of the message.
|
||||
WriteHeader(bytes, offset, core_size, next_extension);
|
||||
|
||||
return next_extension;
|
||||
}
|
||||
void File::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset) {
|
||||
CheckHeader(bytes);
|
||||
|
||||
|
||||
|
||||
auto {field.name}_pointer = bytes.At<ExtPointer>(offset + header_size + (8 * {loop.index}));
|
||||
// Parse path.
|
||||
auto path_pointer = bytes.At<ExtPointer>(offset + header_size + (8 * 0));
|
||||
|
||||
set_path(bytes.StringAt(offset + path_pointer.offset, path_pointer.length));
|
||||
|
||||
|
||||
|
||||
set_attrs(bytes.At<uint64_t>(offset + header_size + (8 * 2)));
|
||||
|
||||
|
||||
|
||||
// Parse attrs.
|
||||
set_attrs(bytes.At<uint64_t>(offset + header_size + (8 * 1)));
|
||||
// Parse mem_cap.
|
||||
// FIXME: Implement in-buffer capabilities for inprocess serialization.
|
||||
set_mem_cap(0);
|
||||
|
||||
|
||||
}
|
||||
|
||||
void {message.name}::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
|
||||
void File::ParseFromBytes(const glcr::ByteBuffer& bytes, uint64_t offset, const glcr::CapBuffer& caps) {
|
||||
CheckHeader(bytes);
|
||||
|
||||
|
||||
|
||||
auto {field.name}_pointer = bytes.At<ExtPointer>(offset + header_size + (8 * {loop.index}));
|
||||
// Parse path.
|
||||
auto path_pointer = bytes.At<ExtPointer>(offset + header_size + (8 * 0));
|
||||
|
||||
set_path(bytes.StringAt(offset + path_pointer.offset, path_pointer.length));
|
||||
|
||||
|
||||
|
||||
set_attrs(bytes.At<uint64_t>(offset + header_size + (8 * 2)));
|
||||
|
||||
|
||||
|
||||
uint64_t mem_cap_ptr = bytes.At<uint64_t>(offset + header_size + (8 * {offset}));
|
||||
// Parse attrs.
|
||||
set_attrs(bytes.At<uint64_t>(offset + header_size + (8 * 1)));
|
||||
// Parse mem_cap.
|
||||
uint64_t mem_cap_ptr = bytes.At<uint64_t>(offset + header_size + (8 * 2));
|
||||
|
||||
set_mem_cap(caps.At(mem_cap_ptr));
|
||||
|
||||
|
||||
}
|
||||
|
||||
uint64_t File::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset) {
|
||||
uint32_t next_extension = header_size + 8 * 3;
|
||||
const uint32_t core_size = next_extension;
|
||||
// Write path.
|
||||
ExtPointer path_ptr{
|
||||
.offset = next_extension,
|
||||
// FIXME: Check downcast of str length.
|
||||
.length = (uint32_t)path().length(),
|
||||
};
|
||||
|
||||
bytes.WriteStringAt(offset + next_extension, path());
|
||||
next_extension += path_ptr.length;
|
||||
|
||||
bytes.WriteAt<ExtPointer>(offset + header_size + (8 * 0), path_ptr);
|
||||
// Write attrs.
|
||||
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 1), attrs());
|
||||
// Write mem_cap.
|
||||
// FIXME: Implement inbuffer capabilities.
|
||||
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 2), 0);
|
||||
|
||||
// The next extension pointer is the length of the message.
|
||||
WriteHeader(bytes, offset, core_size, next_extension);
|
||||
|
||||
return next_extension;
|
||||
}
|
||||
|
||||
uint64_t File::SerializeToBytes(glcr::ByteBuffer& bytes, uint64_t offset, glcr::CapBuffer& caps) {
|
||||
uint32_t next_extension = header_size + 8 * 3;
|
||||
const uint32_t core_size = next_extension;
|
||||
uint64_t next_cap = 0;
|
||||
// Write path.
|
||||
ExtPointer path_ptr{
|
||||
.offset = next_extension,
|
||||
// FIXME: Check downcast of str length.
|
||||
.length = (uint32_t)path().length(),
|
||||
};
|
||||
|
||||
bytes.WriteStringAt(offset + next_extension, path());
|
||||
next_extension += path_ptr.length;
|
||||
|
||||
bytes.WriteAt<ExtPointer>(offset + header_size + (8 * 0), path_ptr);
|
||||
// Write attrs.
|
||||
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 1), attrs());
|
||||
// Write mem_cap.
|
||||
caps.WriteAt(next_cap, mem_cap());
|
||||
bytes.WriteAt<uint64_t>(offset + header_size + (8 * 2), next_cap++);
|
||||
|
||||
// The next extension pointer is the length of the message.
|
||||
WriteHeader(bytes, offset, core_size, next_extension);
|
||||
|
||||
return next_extension;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue