DescriptionAdd 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 : #
Messages
Total messages: 8 (0 generated)
|