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

WebIDL operators fix #6879

Merged
merged 2 commits into from
Jul 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions tests/webidl/output_ALL.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ object
21.12
198
getAsArray: 24
Inner::+= => 2
0
1
34,34
Expand Down
1 change: 1 addition & 0 deletions tests/webidl/output_DEFAULT.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ object
21.12
198
getAsArray: 24
Inner::+= => 2
0
1
34,34
Expand Down
1 change: 1 addition & 0 deletions tests/webidl/output_FAST.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ object
21.12
198
getAsArray: 24
Inner::+= => 2
0
1
34,34
Expand Down
1 change: 1 addition & 0 deletions tests/webidl/post.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ bv2.getAnother().PrintFloat(21.12);
console.log(new TheModule.Inner().get());
console.log('getAsArray: ' + new TheModule.Inner().getAsArray(12));
new TheModule.Inner().mul(2);
new TheModule.Inner().incInPlace(new TheModule.Inner());

console.log(TheModule.enum_value1);
console.log(TheModule.enum_value2);
Expand Down
7 changes: 6 additions & 1 deletion tests/webidl/test.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,15 @@ struct VoidPointerUser {

namespace Space {
struct Inner {
Inner() {}
int value;
Inner() : value(1) {}
int get() { return 198; }
Inner& operator*=(float x) { return *this; }
int operator[](int x) { return x*2; }
void operator+=(const Inner& other) {
value += other.value;
printf("Inner::+= => %d\n", value);
}
};
}

Expand Down
1 change: 1 addition & 0 deletions tests/webidl/test.idl
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ interface Inner {
long get();
[Operator="*=", Ref] Inner mul(float x);
[Operator="[]"] long getAsArray(long x);
[Operator="+="] void incInPlace([Const, Ref] Inner i);
};

enum AnEnum {
Expand Down
2 changes: 1 addition & 1 deletion tools/ports/binaryen.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os, shutil, logging

TAG = 'version_48'
TAG = 'version_49'

def needed(settings, shared, ports):
if not settings.WASM: return False
Expand Down
2 changes: 1 addition & 1 deletion tools/webidl_binder.py
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ def render_function(class_name, func_name, sigs, return_type, non_pointer, copy,
if class_name != func_scope:
# this function comes from an ancestor class; for operators, we must cast it
cast_self = 'dynamic_cast<' + type_to_c(func_scope) + '>(' + cast_self + ')'
maybe_deref = '*' if sig[0] in interfaces else ''
maybe_deref = deref_if_nonpointer(raw[0])
if '=' in operator:
call = '(*%s %s %s%s)' % (cast_self, operator, maybe_deref, args[0])
elif operator == '[]':
Expand Down