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

Side by Side Diff: samples/sample_extension/sample_extension.cc

Issue 43483004: Remove the reply port form the native isolate handler (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated to new isolate API Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « samples/sample_extension/sample_asynchronous_extension.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 #include <string.h> 4 #include <string.h>
5 #include <stdlib.h> 5 #include <stdlib.h>
6 #include <stdio.h> 6 #include <stdio.h>
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "include/dart_native_api.h" 8 #include "include/dart_native_api.h"
9 9
10 Dart_NativeFunction ResolveName(Dart_Handle name, int argc); 10 Dart_NativeFunction ResolveName(Dart_Handle name, int argc);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 uint8_t* values = reinterpret_cast<uint8_t*>(malloc(length)); 53 uint8_t* values = reinterpret_cast<uint8_t*>(malloc(length));
54 if (NULL == values) return NULL; 54 if (NULL == values) return NULL;
55 srand(seed); 55 srand(seed);
56 for (int i = 0; i < length; ++i) { 56 for (int i = 0; i < length; ++i) {
57 values[i] = rand() % 256; 57 values[i] = rand() % 256;
58 } 58 }
59 return values; 59 return values;
60 } 60 }
61 61
62 void wrappedRandomArray(Dart_Port dest_port_id, 62 void wrappedRandomArray(Dart_Port dest_port_id,
63 Dart_Port reply_port_id,
64 Dart_CObject* message) { 63 Dart_CObject* message) {
64 Dart_Port reply_port_id = ILLEGAL_PORT;
65 if (message->type == Dart_CObject_kArray && 65 if (message->type == Dart_CObject_kArray &&
66 2 == message->value.as_array.length) { 66 3 == message->value.as_array.length) {
67 // Use .as_array and .as_int32 to access the data in the Dart_CObject. 67 // Use .as_array and .as_int32 to access the data in the Dart_CObject.
68 Dart_CObject* param0 = message->value.as_array.values[0]; 68 Dart_CObject* param0 = message->value.as_array.values[0];
69 Dart_CObject* param1 = message->value.as_array.values[1]; 69 Dart_CObject* param1 = message->value.as_array.values[1];
70 Dart_CObject* param2 = message->value.as_array.values[2];
70 if (param0->type == Dart_CObject_kInt32 && 71 if (param0->type == Dart_CObject_kInt32 &&
71 param1->type == Dart_CObject_kInt32) { 72 param1->type == Dart_CObject_kInt32 &&
73 param2->type == Dart_CObject_kSendPort) {
72 int seed = param0->value.as_int32; 74 int seed = param0->value.as_int32;
73 int length = param1->value.as_int32; 75 int length = param1->value.as_int32;
74 76 reply_port_id = param2->value.as_send_port;
75 uint8_t* values = randomArray(seed, length); 77 uint8_t* values = randomArray(seed, length);
76 78
77 if (values != NULL) { 79 if (values != NULL) {
78 Dart_CObject result; 80 Dart_CObject result;
79 result.type = Dart_CObject_kTypedData; 81 result.type = Dart_CObject_kTypedData;
80 result.value.as_typed_data.type = Dart_TypedData_kUint8; 82 result.value.as_typed_data.type = Dart_TypedData_kUint8;
81 result.value.as_typed_data.values = values; 83 result.value.as_typed_data.values = values;
82 result.value.as_typed_data.length = length; 84 result.value.as_typed_data.length = length;
83 Dart_PostCObject(reply_port_id, &result); 85 Dart_PostCObject(reply_port_id, &result);
84 free(values); 86 free(values);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 128
127 for (int i=0; function_list[i].name != NULL; ++i) { 129 for (int i=0; function_list[i].name != NULL; ++i) {
128 if (strcmp(function_list[i].name, cname) == 0) { 130 if (strcmp(function_list[i].name, cname) == 0) {
129 result = function_list[i].function; 131 result = function_list[i].function;
130 break; 132 break;
131 } 133 }
132 } 134 }
133 Dart_ExitScope(); 135 Dart_ExitScope();
134 return result; 136 return result;
135 } 137 }
OLDNEW
« no previous file with comments | « samples/sample_extension/sample_asynchronous_extension.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698