Make from_file() and from_string() classmethod functions.

This prevents the user from modifying an mjSpec and then calling the functions to load it from string/file.

PiperOrigin-RevId: 679311284
Change-Id: I4f1ae3cc8f15bece245f624303470d538deec410
This commit is contained in:
Alessio Quaglino
2024-09-26 15:15:01 -07:00
committed by Copybara-Service
parent 8bbf9c7b4f
commit 6a415da267
3 changed files with 106 additions and 93 deletions
+4 -2
View File
@@ -177,8 +177,10 @@ int mjs_isWarning(mjSpec* s) {
// delete model
void mj_deleteSpec(mjSpec* s) {
mjCModel* model = static_cast<mjCModel*>(s->element);
delete model;
if (s) {
mjCModel* model = static_cast<mjCModel*>(s->element);
delete model;
}
}