Change mj_encode return type to 64-bit (mjtSize)

This supports encoding files larger than 2GB.

PiperOrigin-RevId: 939828697
Change-Id: If60d36c61475ced20b4eb58408ffb37e25bf3db7
This commit is contained in:
Sam Haves
2026-06-29 07:41:23 -07:00
committed by Copybara-Service
parent 1e04c568e8
commit d83ef0b6b9
11 changed files with 32 additions and 27 deletions
+1 -1
View File
@@ -436,7 +436,7 @@ FUNCTIONS: Mapping[str, FunctionDecl] = dict([
('mj_encode',
FunctionDecl(
name='mj_encode',
return_type=ValueType(name='int'),
return_type=ValueType(name='mjtSize'),
parameters=(
FunctionParameterDecl(
name='s',
+3 -3
View File
@@ -545,7 +545,7 @@ PYBIND11_MODULE(_specs, m) {
"encode",
[](MjSpec& self, std::string filename,
std::optional<py::object> model,
std::optional<std::string> content_type) -> int {
std::optional<std::string> content_type) -> mjtSize {
raw::MjModel* m = nullptr;
if (model.has_value() && !model->is_none()) {
auto& wrapper =
@@ -572,8 +572,8 @@ PYBIND11_MODULE(_specs, m) {
err[0] = '\0';
const char* ct =
content_type.has_value() ? content_type->c_str() : nullptr;
int nbytes = mj_encode(self.ptr, m, filename.c_str(), ct,
vfs_ptr, err.data(), err.size());
mjtSize nbytes = mj_encode(self.ptr, m, filename.c_str(), ct,
vfs_ptr, err.data(), err.size());
if (vfs_ptr) {
mj_deleteVFS(vfs_ptr);