Skip to content

Commit

Permalink
Fix type-related issues in dependent code. Remove hardcoded mjUSEDOUB…
Browse files Browse the repository at this point in the history
…LE. Add mjUSESINGLE compiler flag.

This CL does not change the default build behavior of MuJoCo. To use single-precision floating-point, build MuJoCo with `-DmjUSESINGLE`.

PiperOrigin-RevId: 644782648
Change-Id: I031fbc20132f3d348f7dbd2d1cb3dd53aaa5c75e
  • Loading branch information
yuvaltassa authored and copybara-github committed Jun 19, 2024
1 parent ed42450 commit 0d35c66
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion dm_control/autowrap/header_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,19 @@ def _nested_if_else(if_, pred, else_, endif, match_if_true, match_if_false):
return ifelse


def _nested_ifn_else(ifn_, pred, else_, endif, match_if_true, match_if_false):
"""Constructs a parser for (possibly nested) if...(else)...endif blocks."""
ifnelse = pp.Forward()
ifnelse << pp.Group( # pylint: disable=expression-not-assigned
ifn_ +
pred("predicate") +
pp.ZeroOrMore(match_if_true | ifnelse)("if_false") +
pp.Optional(else_ +
pp.ZeroOrMore(match_if_false | ifnelse)("if_true")) +
endif)
return ifnelse


# Some common string patterns to suppress.
# ------------------------------------------------------------------------------
(LPAREN, RPAREN, LBRACK, RBRACK, LBRACE, RBRACE, SEMI, COMMA, EQUAL, FSLASH,
Expand Down Expand Up @@ -189,7 +202,9 @@ def _nested_if_else(if_, pred, else_, endif, match_if_true, match_if_false):
UNCOND_DECL = DEF_FLAG | DEF_CONST | TYPE_DECL

# Declarations inside (possibly nested) #if(n)def... #else... #endif... blocks.
COND_DECL = _nested_if_else(IFDEF, NAME, ELSE, ENDIF, UNCOND_DECL, UNCOND_DECL)
COND_DECL = _nested_if_else(
IFDEF, NAME, ELSE, ENDIF, UNCOND_DECL, UNCOND_DECL
) | _nested_ifn_else(IFNDEF, NAME, ELSE, ENDIF, UNCOND_DECL, UNCOND_DECL)
# Note: this doesn't work for '#if defined(FLAG)' blocks

# e.g. "mjtNum gravity[3]; // gravitational acceleration"
Expand Down

0 comments on commit 0d35c66

Please sign in to comment.