mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-03 06:28:27 -04:00
AP_Scripting: generator: allow fields on ap_objects
This commit is contained in:
parent
ad1bf0b59e
commit
00efc1c926
@ -1222,8 +1222,11 @@ void handle_ap_object(void) {
|
||||
} else if (strcmp(type, keyword_manual) == 0) {
|
||||
handle_manual(node, ALIAS_TYPE_MANUAL);
|
||||
|
||||
} else if (strcmp(type, keyword_field) == 0) {
|
||||
handle_userdata_field(node);
|
||||
|
||||
} else {
|
||||
error(ERROR_SINGLETON, "AP_Objects only support renames, methods, semaphore or manual keywords (got %s)", type);
|
||||
error(ERROR_SINGLETON, "AP_Objects only support renames, methods, field, semaphore or manual keywords (got %s)", type);
|
||||
}
|
||||
|
||||
// check that we didn't just add 2 singleton flags
|
||||
@ -1830,6 +1833,28 @@ void emit_singleton_fields() {
|
||||
}
|
||||
}
|
||||
|
||||
void emit_ap_object_field(const struct userdata *data, const struct userdata_field *field) {
|
||||
fprintf(source, "static int %s_%s(lua_State *L) {\n", data->sanatized_name, field->name);
|
||||
fprintf(source, " %s *ud = *check_%s(L, 1);\n", data->name, data->sanatized_name);
|
||||
emit_field(field, "ud", "->");
|
||||
}
|
||||
|
||||
void emit_ap_object_fields() {
|
||||
struct userdata * node = parsed_ap_objects;
|
||||
while(node) {
|
||||
struct userdata_field *field = node->fields;
|
||||
if (field) {
|
||||
start_dependency(source, node->dependency);
|
||||
while(field) {
|
||||
emit_ap_object_field(node, field);
|
||||
field = field->next;
|
||||
}
|
||||
end_dependency(source, node->dependency);
|
||||
}
|
||||
node = node->next;
|
||||
}
|
||||
}
|
||||
|
||||
// emit refences functions for a call, return the number of arduments added
|
||||
int emit_references(const struct argument *arg, const char * tab) {
|
||||
int arg_index = NULLABLE_ARG_COUNT_BASE + 2;
|
||||
@ -3162,7 +3187,7 @@ int main(int argc, char **argv) {
|
||||
emit_methods(parsed_userdata);
|
||||
emit_index(parsed_userdata);
|
||||
|
||||
|
||||
emit_ap_object_fields();
|
||||
emit_methods(parsed_ap_objects);
|
||||
emit_index(parsed_ap_objects);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user