Skip to content

Commit 0d35c66

Browse files
yuvaltassacopybara-github
authored andcommitted
Fix type-related issues in dependent code. Remove hardcoded mjUSEDOUBLE. 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
1 parent ed42450 commit 0d35c66

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

dm_control/autowrap/header_parsing.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,19 @@ def _nested_if_else(if_, pred, else_, endif, match_if_true, match_if_false):
7878
return ifelse
7979

8080

81+
def _nested_ifn_else(ifn_, pred, else_, endif, match_if_true, match_if_false):
82+
"""Constructs a parser for (possibly nested) if...(else)...endif blocks."""
83+
ifnelse = pp.Forward()
84+
ifnelse << pp.Group( # pylint: disable=expression-not-assigned
85+
ifn_ +
86+
pred("predicate") +
87+
pp.ZeroOrMore(match_if_true | ifnelse)("if_false") +
88+
pp.Optional(else_ +
89+
pp.ZeroOrMore(match_if_false | ifnelse)("if_true")) +
90+
endif)
91+
return ifnelse
92+
93+
8194
# Some common string patterns to suppress.
8295
# ------------------------------------------------------------------------------
8396
(LPAREN, RPAREN, LBRACK, RBRACK, LBRACE, RBRACE, SEMI, COMMA, EQUAL, FSLASH,
@@ -189,7 +202,9 @@ def _nested_if_else(if_, pred, else_, endif, match_if_true, match_if_false):
189202
UNCOND_DECL = DEF_FLAG | DEF_CONST | TYPE_DECL
190203

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

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

0 commit comments

Comments
 (0)