-
Notifications
You must be signed in to change notification settings - Fork 3.4k
[embind] Change how the number of arguments are verified. #22591
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,10 @@ | ||
| { | ||
| "a.html": 552, | ||
| "a.html.gz": 380, | ||
| "a.js": 9910, | ||
| "a.js.gz": 4352, | ||
| "a.js": 9727, | ||
| "a.js.gz": 4295, | ||
| "a.wasm": 7728, | ||
| "a.wasm.gz": 3519, | ||
| "total": 18190, | ||
| "total_gz": 8251 | ||
| "total": 18007, | ||
| "total_gz": 8194 | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1294,6 +1294,20 @@ module({ | |
| value = cm.embind_test_optional_small_class_arg(undefined); | ||
| assert.equal(-1, value); | ||
| }); | ||
|
|
||
| test("std::optional args can be omitted", function() { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about arguments that have default values? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Embind doesn't really support default C++ arguments. Functions with default arguments just look like regular functions to embind. e.g. |
||
| if (cm.getCompilerSetting('ASSERTIONS')) { | ||
| // Argument length is only validated with assertions enabled. | ||
| assert.throws(cm.BindingError, function() { | ||
| cm.embind_test_optional_multiple_arg(); | ||
| }); | ||
| assert.throws(cm.BindingError, function() { | ||
| cm.embind_test_optional_multiple_arg(1, 2, 3, 4); | ||
| }); | ||
| } | ||
| cm.embind_test_optional_multiple_arg(1); | ||
| cm.embind_test_optional_multiple_arg(1, 2); | ||
| }); | ||
| }); | ||
|
|
||
| BaseFixture.extend("functors", function() { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a followup can this be arrow function in some cases?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll look into it. This is also used in constructors so having the scope bound, may be an issue.