AP_Scripting/generator: allow disabling userdata creation from Lua

Passing -1 to the argument count for the `creation` tag (name does not
matter) will stop the generator from giving Lua a function to construct
that userdata. The C `new_<name>` function still works.
This commit is contained in:
Thomas Watson 2024-06-16 16:13:21 -05:00 committed by Peter Barker
parent 7fb65aece3
commit c37dba60de

View File

@ -2568,8 +2568,8 @@ void emit_sandbox(void) {
// Dont expose creation function for all read only items
int expose_creation = FALSE;
if (data->creation || data->methods) {
// Custom creation or methods
expose_creation = TRUE;
// Custom creation or methods, if not specifically disabled
expose_creation = !(data->creation && data->creation_args == -1);
} else {
// Feilds only
struct userdata_field * field = data->fields;
@ -2866,7 +2866,8 @@ void emit_docs(struct userdata *node, int is_userdata, int emit_creation) {
// local userdata
fprintf(docs, "local %s = {}\n\n", name);
if (emit_creation) {
int creation_disabled = (node->creation && node->creation_args == -1);
if (emit_creation && (!node->creation || !creation_disabled)) {
// creation function
if (node->creation != NULL) {
for (int i = 0; i < node->creation_args; ++i) {