OLD | NEW |
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 "dart_api.h" | 7 #include "dart_api.h" |
8 | 8 |
9 Dart_NativeFunction ResolveName(Dart_Handle name, int argc); | 9 Dart_NativeFunction ResolveName(Dart_Handle name, int argc); |
10 | 10 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 Dart_CObject* param1 = message->value.as_array.values[1]; | 68 Dart_CObject* param1 = message->value.as_array.values[1]; |
69 if (param0->type == Dart_CObject::kInt32 && | 69 if (param0->type == Dart_CObject::kInt32 && |
70 param1->type == Dart_CObject::kInt32) { | 70 param1->type == Dart_CObject::kInt32) { |
71 int length = param0->value.as_int32; | 71 int length = param0->value.as_int32; |
72 int seed = param1->value.as_int32; | 72 int seed = param1->value.as_int32; |
73 | 73 |
74 uint8_t* values = randomArray(seed, length); | 74 uint8_t* values = randomArray(seed, length); |
75 | 75 |
76 if (values != NULL) { | 76 if (values != NULL) { |
77 Dart_CObject result; | 77 Dart_CObject result; |
78 result.type = Dart_CObject::kUint8Array; | 78 result.type = Dart_CObject::kTypedData; |
79 result.value.as_byte_array.values = values; | 79 result.value.as_typed_data.type = Dart_CObject::kUint8Array; |
80 result.value.as_byte_array.length = length; | 80 result.value.as_typed_data.values = values; |
| 81 result.value.as_typed_data.length = length; |
81 Dart_PostCObject(reply_port_id, &result); | 82 Dart_PostCObject(reply_port_id, &result); |
82 free(values); | 83 free(values); |
83 // It is OK that result is destroyed when function exits. | 84 // It is OK that result is destroyed when function exits. |
84 // Dart_PostCObject has copied its data. | 85 // Dart_PostCObject has copied its data. |
85 return; | 86 return; |
86 } | 87 } |
87 } | 88 } |
88 } | 89 } |
89 Dart_CObject result; | 90 Dart_CObject result; |
90 result.type = Dart_CObject::kNull; | 91 result.type = Dart_CObject::kNull; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 | 125 |
125 for (int i=0; function_list[i].name != NULL; ++i) { | 126 for (int i=0; function_list[i].name != NULL; ++i) { |
126 if (strcmp(function_list[i].name, cname) == 0) { | 127 if (strcmp(function_list[i].name, cname) == 0) { |
127 result = function_list[i].function; | 128 result = function_list[i].function; |
128 break; | 129 break; |
129 } | 130 } |
130 } | 131 } |
131 Dart_ExitScope(); | 132 Dart_ExitScope(); |
132 return result; | 133 return result; |
133 } | 134 } |
OLD | NEW |