Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating API to include the union types for mjuiItem #1006

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
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
4 changes: 4 additions & 0 deletions include/mujoco/mjui.h
Original file line number Diff line number Diff line change
Expand Up @@ -208,24 +208,28 @@ struct mjuiItemSingle_ { // check and button-related
int modifier; // 0: none, 1: control, 2: shift; 4: alt
int shortcut; // shortcut key; 0: undefined
};
typedef struct mjuiItemSingle_ mjuiItemSingle;


struct mjuiItemMulti_ { // static, radio and select-related
int nelem; // number of elements in group
char name[mjMAXUIMULTI][mjMAXUINAME]; // element names
};
typedef struct mjuiItemMulti_ mjuiItemMulti;


struct mjuiItemSlider_ { // slider-related
double range[2]; // slider range
double divisions; // number of range divisions
};
typedef struct mjuiItemSlider_ mjuiItemSlider;


struct mjuiItemEdit_ { // edit-related
int nelem; // number of elements in list
double range[mjMAXUIEDIT][2]; // element range (min>=max: ignore)
};
typedef struct mjuiItemEdit_ mjuiItemEdit;


struct mjuiItem_ { // UI item
Expand Down
4 changes: 2 additions & 2 deletions introspect/codegen/generate_enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
# ==============================================================================
"""Generates enums.py.

The JSON input can be generated via:
clang -Xclang -ast-dump=json -fsyntax-only -fparse-all-comments -x c mujoco.h
The JSON input can be generated via running the following in the `mujoco/include` directory:
clang -Xclang -ast-dump=json -fsyntax-only -fparse-all-comments -x c -I$(pwd) mujoco/mujoco.h
"""

import json
Expand Down
4 changes: 2 additions & 2 deletions introspect/codegen/generate_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
# ==============================================================================
"""Generates functions.py.

The JSON input can be generated via:
clang -Xclang -ast-dump=json -fsyntax-only -fparse-all-comments -x c mujoco.h
The JSON input can be generated via running the following in the `mujoco/include` directory:
clang -Xclang -ast-dump=json -fsyntax-only -fparse-all-comments -x c -I$(pwd) mujoco/mujoco.h
"""

import json
Expand Down
4 changes: 2 additions & 2 deletions introspect/codegen/generate_structs.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
# ==============================================================================
"""Generates structs.py.

The JSON input can be generated via:
clang -Xclang -ast-dump=json -fsyntax-only -fparse-all-comments -x c mujoco.h
The JSON input can be generated via running the following in the `mujoco/include` directory:
clang -Xclang -ast-dump=json -fsyntax-only -fparse-all-comments -x c -I$(pwd) mujoco/mujoco.h
"""

import itertools
Expand Down
85 changes: 81 additions & 4 deletions introspect/structs.py
Original file line number Diff line number Diff line change
Expand Up @@ -7134,6 +7134,83 @@
),
),
)),
('mjuiItemSingle',
StructDecl(
name='mjuiItemSingle',
declname='struct mjuiItemSingle_',
fields=(
StructFieldDecl(
name='modifier',
type=ValueType(name='int'),
doc='0: none, 1: control, 2: shift; 4: alt',
),
StructFieldDecl(
name='shortcut',
type=ValueType(name='int'),
doc='shortcut key; 0: undefined',
),
),
)),
('mjuiItemMulti',
StructDecl(
name='mjuiItemMulti',
declname='struct mjuiItemMulti_',
fields=(
StructFieldDecl(
name='nelem',
type=ValueType(name='int'),
doc='number of elements in group',
),
StructFieldDecl(
name='name',
type=ArrayType(
inner_type=ValueType(name='char'),
extents=(35, 40),
),
doc='element names',
),
),
)),
('mjuiItemSlider',
StructDecl(
name='mjuiItemSlider',
declname='struct mjuiItemSlider_',
fields=(
StructFieldDecl(
name='range',
type=ArrayType(
inner_type=ValueType(name='double'),
extents=(2,),
),
doc='slider range',
),
StructFieldDecl(
name='divisions',
type=ValueType(name='double'),
doc='number of range divisions',
),
),
)),
('mjuiItemEdit',
StructDecl(
name='mjuiItemEdit',
declname='struct mjuiItemEdit_',
fields=(
StructFieldDecl(
name='nelem',
type=ValueType(name='int'),
doc='number of elements in list',
),
StructFieldDecl(
name='range',
type=ArrayType(
inner_type=ValueType(name='double'),
extents=(7, 2),
),
doc='element range (min>=max: ignore)',
),
),
)),
('mjuiItem',
StructDecl(
name='mjuiItem',
Expand Down Expand Up @@ -7178,22 +7255,22 @@
fields=(
StructFieldDecl(
name='single',
type=ValueType(name='struct mjuiItemSingle_'),
type=ValueType(name='mjuiItemSingle'),
doc='check and button',
),
StructFieldDecl(
name='multi',
type=ValueType(name='struct mjuiItemMulti_'),
type=ValueType(name='mjuiItemMulti'),
doc='static, radio and select',
),
StructFieldDecl(
name='slider',
type=ValueType(name='struct mjuiItemSlider_'),
type=ValueType(name='mjuiItemSlider'),
doc='slider',
),
StructFieldDecl(
name='edit',
type=ValueType(name='struct mjuiItemEdit_'),
type=ValueType(name='mjuiItemEdit'),
doc='edit',
),
),
Expand Down