Skip to content

sdk: prerun+varargs#254

Open
dbentley-vsql wants to merge 1 commit into
mainfrom
dbentley/sdk_varargs
Open

sdk: prerun+varargs#254
dbentley-vsql wants to merge 1 commit into
mainfrom
dbentley/sdk_varargs

Conversation

@dbentley-vsql
Copy link
Copy Markdown
Member

It appears we accidentally blocked varargs functions. Even though we could set a prerun, the calls (or lack of) to .params would still be checked and throw an error.

Copy link
Copy Markdown
Member

@malone-at-work malone-at-work left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am going to think about this a little more; I think there may be better ways to guide people to use this correctly

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we making changes to this file - this is only for older extensions to keep compiling.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted. Thanks.

}

private:
static void config_error__param_type_and_varargs_are_mutually_exclusive();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason we can't use static_assert for these?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hah; I had done that but reverted it because it added a template parameter. Now it's static_assert again.

// FuncBuilder
// =============================================================================

enum class ParamMode { kUndeclared, kFixed, kVarargs };
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/kUndeclared/kUnset/?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

}

private:
static void config_error__param_type_and_varargs_are_mutually_exclusive();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This way of inducing an error worries me, can you add a test that this fails, especially with the following cmake option:

  target_link_options(foo_ext PRIVATE -undefined dynamic_lookup)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's static_assert now.

for (unsigned int i = 0; i < value_count; i++) {
Item *arg_item = args[i];
vef_type_id param_type =
(i < sig->param_count) ? sig->params[i].id : VEF_TYPE_STRING;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did I write this? Is this intentional that we marshall excess parameters to functions? I think we should probably make this an error (except in the varargs) case.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think it was untested and was handled by a separate error. Commented.

if (args->arg_count == 0) {
result->type = VEF_RESULT_ERROR;
snprintf(result->error_msg, VEF_MAX_ERROR_LEN,
"ba_concat_all requires at least one argument");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please test these errors.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done (extension_simple_type_usage.result)

vef_type_id id = args->arg_types[i].id;
if (id != VEF_TYPE_CUSTOM && id != VEF_TYPE_STRING) {
result->type = VEF_RESULT_ERROR;
snprintf(result->error_msg, VEF_MAX_ERROR_LEN,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This too.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done (see above)

.param(BYTEARRAY)
.build())
.func(make_func<&ba_len>("ba_len").returns(INT).param().build())
.func(make_func<&ba_concat_all>("ba_concat_all")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what would you think of a make_varargs_func() that doesn't allow you to specify parameters?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why put varargs in the func name when everything else is methods on the builder?

@dbentley-vsql dbentley-vsql force-pushed the dbentley/sdk_varargs branch from 5097983 to 832caae Compare May 15, 2026 14:36
@dbentley-vsql dbentley-vsql force-pushed the dbentley/sdk_varargs branch from 832caae to 74833e7 Compare May 15, 2026 14:45
@malone-at-work malone-at-work self-requested a review May 15, 2026 16:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants