Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Google deepmind Mujoco WASM Bindings Template

From Leeroopedia
Revision as of 12:47, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/Google_deepmind_Mujoco_WASM_Bindings_Template.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Knowledge Sources
Domains WebAssembly, Code Generation, Template
Last Updated 2026-02-15 04:00 GMT

Overview

Provides the C++ template file used as the base for generating the WASM Embind bindings, containing hand-written binding code and insertion points for generated code.

Description

bindings.cc (in the templates directory) serves as the skeleton for the auto-generated bindings file. It contains the same Emscripten includes, namespace setup, and MJMODEL_ACCESSORS macro definitions as the generated output, but with placeholder sections where the code generator inserts auto-generated struct wrappers, function wrappers, and enum bindings. The template includes hand-written utility code such as the accessor macros for all MuJoCo object types, custom Embind value type declarations, and any manually maintained binding logic that cannot be auto-generated.

Usage

Used as the input template by the WASM code generation pipeline, which reads this file, inserts generated code at marked locations, and produces the final bindings.cc in the generated directory.

Code Reference

Source Location

Key Functions

namespace mujoco::wasm {

EMSCRIPTEN_DECLARE_VAL_TYPE(NumberOrString);
EMSCRIPTEN_DECLARE_VAL_TYPE(NumberArray);
EMSCRIPTEN_DECLARE_VAL_TYPE(String);
EMSCRIPTEN_DECLARE_VAL_TYPE(StringOrNull);

#define MJMODEL_ACCESSORS \
  X_ACCESSOR(ACTUATOR, Actuator, mjOBJ_ACTUATOR, actuator, nu) \
  // ... template for all object types

// Insertion points for generated struct/function/enum code
}

Import

#include <emscripten.h>
#include <emscripten/bind.h>
#include <emscripten/val.h>
#include <mujoco/mujoco.h>
#include "wasm/unpack.h"

I/O Contract

Inputs

Name Type Required Description
Template file C++ source Yes This file serves as the template skeleton for code generation

Outputs

Name Type Description
Generated bindings.cc C++ source Final auto-generated file with all binding code inserted

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment