Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,21 @@ rm -rf "$SCRIPT_DIR/generated/lua_lcm_msgs"
echo -e "\033[32mLCM -> Lua done\033[0m"

# Generate TypeScript bindings
rm -rf "$SCRIPT_DIR/generated/ts_lcm_msgs"
# Only the per-package directories are generated; anything else in there is
# hand-written, so clear the packages instead of the whole tree.
mkdir -p "$SCRIPT_DIR/generated/ts_lcm_msgs"
find "$SCRIPT_DIR/generated/ts_lcm_msgs" -mindepth 1 -maxdepth 1 -type d -exec rm -rf {} +
deno run --allow-read --allow-write "$SCRIPT_DIR/tools/ts/gen/mod.ts" -q -o "$SCRIPT_DIR/generated/ts_lcm_msgs" "$SCRIPT_DIR/lcm_types"/*.lcm
# Copy to msgs package (for JSR publishing - symlinks not supported)
rm -rf "$SCRIPT_DIR/tools/ts/msgs/generated"
cp -r "$SCRIPT_DIR/generated/ts_lcm_msgs" "$SCRIPT_DIR/tools/ts/msgs/generated"
mkdir -p "$SCRIPT_DIR/tools/ts/msgs/generated"
cp -r "$SCRIPT_DIR/generated/ts_lcm_msgs"/*/ "$SCRIPT_DIR/tools/ts/msgs/generated/"
echo -e "\033[32mLCM -> TypeScript done\033[0m"

# Generate Rust bindings
rm -rf "$SCRIPT_DIR/generated/rust_lcm_msgs"
# The generator owns src/ and Cargo.toml; tests/, Cargo.lock and .gitignore are
# hand-written, so only clear src/ rather than the whole crate.
rm -rf "$SCRIPT_DIR/generated/rust_lcm_msgs/src"
python3 "$SCRIPT_DIR/tools/rust/lcm_rust_gen.py" "$SCRIPT_DIR/lcm_types" -o "$SCRIPT_DIR/generated/rust_lcm_msgs"
(cd "$SCRIPT_DIR/generated/rust_lcm_msgs" && cargo check --quiet)
echo -e "\033[32mLCM -> Rust done\033[0m"
245 changes: 245 additions & 0 deletions generated/cpp_lcm_msgs/dimos_control_msgs/CommandProfile.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,245 @@
/** THIS IS AN AUTOMATICALLY GENERATED FILE. DO NOT MODIFY
* BY HAND!!
*
* Generated by lcm-gen 1.5.2
**/

#ifndef __dimos_control_msgs_CommandProfile_hpp__
#define __dimos_control_msgs_CommandProfile_hpp__

#include <lcm/lcm_coretypes.h>

#include <string>
#include <vector>

namespace dimos_control_msgs
{

class CommandProfile
{
public:
std::string name;

int32_t required_fields_length;

int32_t optional_fields_length;

/**
* LCM Type: string[required_fields_length]
*/
std::vector< std::string > required_fields;

/**
* LCM Type: string[optional_fields_length]
*/
std::vector< std::string > optional_fields;

int8_t uniform_across_resources;

public:
/**
* Encode a message into binary form.
*
* @param buf The output buffer.
* @param offset Encoding starts at thie byte offset into @p buf.
* @param maxlen Maximum number of bytes to write. This should generally be
* equal to getEncodedSize().
* @return The number of bytes encoded, or <0 on error.
*/
inline int encode(void *buf, int offset, int maxlen) const;

/**
* Check how many bytes are required to encode this message.
*/
inline int getEncodedSize() const;

/**
* Decode a message from binary form into this instance.
*
* @param buf The buffer containing the encoded message.
* @param offset The byte offset into @p buf where the encoded message starts.
* @param maxlen The maximum number of bytes to read while decoding.
* @return The number of bytes decoded, or <0 if an error occured.
*/
inline int decode(const void *buf, int offset, int maxlen);

/**
* Retrieve the 64-bit fingerprint identifying the structure of the message.
* Note that the fingerprint is the same for all instances of the same
* message type, and is a fingerprint on the message type definition, not on
* the message contents.
*/
inline static int64_t getHash();

/**
* Returns "CommandProfile"
*/
inline static const char* getTypeName();

// LCM support functions. Users should not call these
inline int _encodeNoHash(void *buf, int offset, int maxlen) const;
inline int _getEncodedSizeNoHash() const;
inline int _decodeNoHash(const void *buf, int offset, int maxlen);
inline static uint64_t _computeHash(const __lcm_hash_ptr *p);
};

int CommandProfile::encode(void *buf, int offset, int maxlen) const
{
int pos = 0, tlen;
int64_t hash = getHash();

tlen = __int64_t_encode_array(buf, offset + pos, maxlen - pos, &hash, 1);
if(tlen < 0) return tlen; else pos += tlen;

tlen = this->_encodeNoHash(buf, offset + pos, maxlen - pos);
if (tlen < 0) return tlen; else pos += tlen;

return pos;
}

int CommandProfile::decode(const void *buf, int offset, int maxlen)
{
int pos = 0, thislen;

int64_t msg_hash;
thislen = __int64_t_decode_array(buf, offset + pos, maxlen - pos, &msg_hash, 1);
if (thislen < 0) return thislen; else pos += thislen;
if (msg_hash != getHash()) return -1;

thislen = this->_decodeNoHash(buf, offset + pos, maxlen - pos);
if (thislen < 0) return thislen; else pos += thislen;

return pos;
}

int CommandProfile::getEncodedSize() const
{
return 8 + _getEncodedSizeNoHash();
}

int64_t CommandProfile::getHash()
{
static int64_t hash = static_cast<int64_t>(_computeHash(NULL));
return hash;
}

const char* CommandProfile::getTypeName()
{
return "CommandProfile";
}

int CommandProfile::_encodeNoHash(void *buf, int offset, int maxlen) const
{
int pos = 0, tlen;

char* name_cstr = const_cast<char*>(this->name.c_str());
tlen = __string_encode_array(
buf, offset + pos, maxlen - pos, &name_cstr, 1);
if(tlen < 0) return tlen; else pos += tlen;

tlen = __int32_t_encode_array(buf, offset + pos, maxlen - pos, &this->required_fields_length, 1);
if(tlen < 0) return tlen; else pos += tlen;

tlen = __int32_t_encode_array(buf, offset + pos, maxlen - pos, &this->optional_fields_length, 1);
if(tlen < 0) return tlen; else pos += tlen;

for (int a0 = 0; a0 < this->required_fields_length; a0++) {
char* __cstr = const_cast<char*>(this->required_fields[a0].c_str());
tlen = __string_encode_array(
buf, offset + pos, maxlen - pos, &__cstr, 1);
if(tlen < 0) return tlen; else pos += tlen;
}

for (int a0 = 0; a0 < this->optional_fields_length; a0++) {
char* __cstr = const_cast<char*>(this->optional_fields[a0].c_str());
tlen = __string_encode_array(
buf, offset + pos, maxlen - pos, &__cstr, 1);
if(tlen < 0) return tlen; else pos += tlen;
}

tlen = __boolean_encode_array(buf, offset + pos, maxlen - pos, &this->uniform_across_resources, 1);
if(tlen < 0) return tlen; else pos += tlen;

return pos;
}

int CommandProfile::_decodeNoHash(const void *buf, int offset, int maxlen)
{
int pos = 0, tlen;

int32_t __name_len__;
tlen = __int32_t_decode_array(
buf, offset + pos, maxlen - pos, &__name_len__, 1);
if(tlen < 0) return tlen; else pos += tlen;
if(__name_len__ > maxlen - pos) return -1;
this->name.assign(
static_cast<const char*>(buf) + offset + pos, __name_len__ - 1);
pos += __name_len__;

tlen = __int32_t_decode_array(buf, offset + pos, maxlen - pos, &this->required_fields_length, 1);
if(tlen < 0) return tlen; else pos += tlen;

tlen = __int32_t_decode_array(buf, offset + pos, maxlen - pos, &this->optional_fields_length, 1);
if(tlen < 0) return tlen; else pos += tlen;

try {
this->required_fields.resize(this->required_fields_length);
} catch (...) {
return -1;
}
for (int a0 = 0; a0 < this->required_fields_length; a0++) {
int32_t __elem_len;
tlen = __int32_t_decode_array(
buf, offset + pos, maxlen - pos, &__elem_len, 1);
if(tlen < 0) return tlen; else pos += tlen;
if(__elem_len > maxlen - pos) return -1;
this->required_fields[a0].assign(static_cast<const char*>(buf) + offset + pos, __elem_len - 1);
pos += __elem_len;
}

try {
this->optional_fields.resize(this->optional_fields_length);
} catch (...) {
return -1;
}
for (int a0 = 0; a0 < this->optional_fields_length; a0++) {
int32_t __elem_len;
tlen = __int32_t_decode_array(
buf, offset + pos, maxlen - pos, &__elem_len, 1);
if(tlen < 0) return tlen; else pos += tlen;
if(__elem_len > maxlen - pos) return -1;
this->optional_fields[a0].assign(static_cast<const char*>(buf) + offset + pos, __elem_len - 1);
pos += __elem_len;
}

tlen = __boolean_decode_array(buf, offset + pos, maxlen - pos, &this->uniform_across_resources, 1);
if(tlen < 0) return tlen; else pos += tlen;

return pos;
}

int CommandProfile::_getEncodedSizeNoHash() const
{
int enc_size = 0;
enc_size += this->name.size() + 4 + 1;
enc_size += __int32_t_encoded_array_size(NULL, 1);
enc_size += __int32_t_encoded_array_size(NULL, 1);
for (int a0 = 0; a0 < this->required_fields_length; a0++) {
enc_size += this->required_fields[a0].size() + 4 + 1;
}
for (int a0 = 0; a0 < this->optional_fields_length; a0++) {
enc_size += this->optional_fields[a0].size() + 4 + 1;
}
enc_size += __boolean_encoded_array_size(NULL, 1);
return enc_size;
}

uint64_t CommandProfile::_computeHash(const __lcm_hash_ptr *)
{
uint64_t hash = 0x38538e7a9d86eb4aLL;
return (hash<<1) + ((hash>>63)&1);
}

}

#endif
Loading