Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(427)

Issue 282883002: Add a new API function to extract all the native arguments into an array (Closed)

Created:
6 years, 7 months ago by siva
Modified:
6 years, 7 months ago
Reviewers:
vsm, Ivan Posva
CC:
reviews_dartlang.org, vm-dev_dartlang.org
Visibility:
Public.

Description

Add a new API function to extract all the native arguments into an array passed in by the caller. This call can be used in DOM bindings patterns as follows: Old code - Dart_Handle exception = 0; { WebGL* receiver = DartDOMWrapper::receiver< WebGL >(args); unsigned srcRGB = DartUtilities::dartToUnsigned(args, 1, exception); if (exception) goto fail; unsigned dstRGB = DartUtilities::dartToUnsigned(args, 2, exception); if (exception) goto fail; unsigned srcAlpha = DartUtilities::dartToUnsigned(args, 3, exception); if (exception) goto fail; unsigned dstAlpha = DartUtilities::dartToUnsigned(args, 4, exception); if (exception) goto fail; receiver->blendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha); return; } fail: Dart_ThrowException(exception); ASSERT_NOT_REACHED(); Proposed new code - /** * One time initialization code for setting up argument descriptors */ const int kNumArgs = 5; const int kNumNativeFields = 2; static const uint8_t native_arg_descriptor[kNumArgs] = { DART_NATIVE_ARG_DESCRIPTOR(Dart_NativeArgument_kNativeFields, 0), DART_NATIVE_ARG_DESCRIPTOR(Dart_NativeArgument_kUint32, 1), DART_NATIVE_ARG_DESCRIPTOR(Dart_NativeArgument_kUint32, 2), DART_NATIVE_ARG_DESCRIPTOR(Dart_NativeArgument_kUint32, 3), DART_NATIVE_ARG_DESCRIPTOR(Dart_NativeArgument_kUint32, 4), }; Dart_NativeArgument_Value native_args[kNumArgs]; intptr_t native_fields[kNumNativeFields]; native_args[0].as_native_fields.num_fields = kNumNativeFields; native_args[0].as_native_fields.values = native_fields; /** * Code executed for each invocation of the binding method */ Dart_Handle result = Dart_GetNativeArguments(args, kNumArgs, native_arg_descriptor, native_args); if (Dart_IsError(result)) { Dart_ThrowException(result); } WebGL* receiver = DartDOMWrapper::receiver< WebGL >(native_args[0].as_native_fields.values); unsigned srcRGB = native_args[1].as_uint32; unsigned dstRGB = native_args[2].as_uint32; unsigned srcAlpha = native_args[3].as_uint32; unsigned dstAlpha = native_args[4].as_uint32; receiver->blendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha); return; R=iposva@google.com, vsm@google.com Committed: https://code.google.com/p/dart/source/detail?r=36464

Patch Set 1 #

Patch Set 2 : #

Patch Set 3 : #

Patch Set 4 : #

Patch Set 5 : #

Patch Set 6 : #

Total comments: 12

Patch Set 7 : #

Unified diffs Side-by-side diffs Delta from patch set Stats (+652 lines, -96 lines) Patch
M runtime/include/dart_api.h View 1 2 3 4 5 6 1 chunk +75 lines, -0 lines 0 comments Download
M runtime/vm/dart_api_impl.h View 1 2 3 4 5 6 1 chunk +16 lines, -0 lines 0 comments Download
M runtime/vm/dart_api_impl.cc View 1 2 3 4 5 6 8 chunks +360 lines, -94 lines 0 comments Download
M runtime/vm/dart_api_impl_test.cc View 1 2 3 4 5 6 1 chunk +198 lines, -1 line 0 comments Download
M runtime/vm/raw_object.h View 1 2 3 4 5 6 3 chunks +3 lines, -1 line 0 comments Download

Messages

Total messages: 8 (0 generated)
siva
6 years, 7 months ago (2014-05-13 19:53:34 UTC) #1
vsm
lgtm I wonder if it's worth hoisting some of this logic into the resolver / ...
6 years, 7 months ago (2014-05-14 12:30:48 UTC) #2
siva
Tweaked the API a bit to allow for the argument descriptor to be separated from ...
6 years, 7 months ago (2014-05-16 01:07:44 UTC) #3
siva
synched up to top of tree.
6 years, 7 months ago (2014-05-16 21:19:10 UTC) #4
vsm
On 2014/05/16 21:19:10, siva wrote: > synched up to top of tree. lgtm - nice!
6 years, 7 months ago (2014-05-20 10:45:50 UTC) #5
Ivan Posva
LGTM with comments. -Ivan https://codereview.chromium.org/282883002/diff/100001/runtime/include/dart_api.h File runtime/include/dart_api.h (right): https://codereview.chromium.org/282883002/diff/100001/runtime/include/dart_api.h#newcode2190 runtime/include/dart_api.h:2190: kNativeArgNumberSize = 4, How about ...
6 years, 7 months ago (2014-05-20 19:27:03 UTC) #6
siva
https://codereview.chromium.org/282883002/diff/100001/runtime/include/dart_api.h File runtime/include/dart_api.h (right): https://codereview.chromium.org/282883002/diff/100001/runtime/include/dart_api.h#newcode2190 runtime/include/dart_api.h:2190: kNativeArgNumberSize = 4, On 2014/05/20 19:27:03, Ivan Posva wrote: ...
6 years, 7 months ago (2014-05-21 23:56:53 UTC) #7
siva
6 years, 7 months ago (2014-05-22 00:08:29 UTC) #8
Message was sent while issue was closed.
Committed patchset #7 manually as r36464 (presubmit successful).

Powered by Google App Engine
This is Rietveld 408576698