Skip to content
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

embind: Add support for std::nullptr_t #18661

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tritao
Copy link

@tritao tritao commented Feb 4, 2023

As the title says, this adds support for std::nullptr_t types to the Embind. This came up when bootstrapping a pre-existing binding generator test suite to work with Embind target.

Used the sig vpppDn where Dn is the Itanium C++ mangled encoding, but not really sure about the rest of the letters, and couldn't really find any documentation regarding how these signatures mean. Is this documented anywhere?

@kripken kripken requested a review from brendandahl February 7, 2023 17:35
@JeanChristopheMorinPerso
Copy link
Contributor

JeanChristopheMorinPerso commented Feb 9, 2023

I think the first character in the signature represents the return type, in this case v is void and the rest are the types of the arguments, where p is for pointer. https://emscripten.org/docs/porting/connecting_cpp_and_javascript/Interacting-with-code.html#calling-javascript-functions-as-function-pointers-from-c

@@ -74,6 +75,10 @@ val emval_test_passthrough(val v) {
void emval_test_return_void() {
}

std::nullptr_t emval_test_return_nullptr_t() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why would a function have a return type of std::nullptr_t. I've seen it used for overloading with parameters but not this?

@@ -675,6 +675,23 @@ var LibraryEmbind = {
return this['fromWireType']({{{ makeGetValue('pointer', '0', 'i32') }}});
},

_embind_register_std_nullptr_t__sig: 'vpppDn',
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should be vpp.

'fromWireType': function (value) {
return null;
},
'toWireType': function (destructors, value) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think null is a valid wasm type. This should probably be 0.

@@ -74,6 +75,10 @@ val emval_test_passthrough(val v) {
void emval_test_return_void() {
}

std::nullptr_t emval_test_return_nullptr_t() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I also don't see this function bound anywhere. e.g. look at how emval_test_not works.

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.

3 participants