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

Unified Diff: samples/sample_extension/sample_extension.cc

Issue 131103025: Fixes ABI bug in MIPS. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 11 months 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 side-by-side diff with in-line comments
Download patch
Index: samples/sample_extension/sample_extension.cc
===================================================================
--- samples/sample_extension/sample_extension.cc (revision 32137)
+++ samples/sample_extension/sample_extension.cc (working copy)
@@ -7,24 +7,34 @@
#include "include/dart_api.h"
#include "include/dart_native_api.h"
+
Dart_NativeFunction ResolveName(Dart_Handle name,
int argc,
bool* auto_setup_scope);
+
DART_EXPORT Dart_Handle sample_extension_Init(Dart_Handle parent_library) {
- if (Dart_IsError(parent_library)) { return parent_library; }
+ if (Dart_IsError(parent_library)) {
+ return parent_library;
+ }
Dart_Handle result_code = Dart_SetNativeResolver(parent_library, ResolveName);
- if (Dart_IsError(result_code)) return result_code;
+ if (Dart_IsError(result_code)) {
+ return result_code;
+ }
return Dart_Null();
}
+
Dart_Handle HandleError(Dart_Handle handle) {
- if (Dart_IsError(handle)) Dart_PropagateError(handle);
+ if (Dart_IsError(handle)) {
+ Dart_PropagateError(handle);
+ }
return handle;
}
+
void SystemRand(Dart_NativeArguments arguments) {
Dart_EnterScope();
Dart_Handle result = HandleError(Dart_NewInteger(rand()));
@@ -32,6 +42,7 @@
Dart_ExitScope();
}
+
void SystemSrand(Dart_NativeArguments arguments) {
Dart_EnterScope();
bool success = false;
@@ -50,10 +61,15 @@
Dart_ExitScope();
}
+
uint8_t* randomArray(int seed, int length) {
- if (length <= 0 || length > 10000000) return NULL;
+ if (length <= 0 || length > 10000000) {
+ return NULL;
+ }
uint8_t* values = reinterpret_cast<uint8_t*>(malloc(length));
- if (NULL == values) return NULL;
+ if (NULL == values) {
+ return NULL;
+ }
srand(seed);
for (int i = 0; i < length; ++i) {
values[i] = rand() % 256;
@@ -61,6 +77,7 @@
return values;
}
+
void wrappedRandomArray(Dart_Port dest_port_id,
Dart_CObject* message) {
Dart_Port reply_port_id = ILLEGAL_PORT;
@@ -97,6 +114,7 @@
Dart_PostCObject(reply_port_id, &result);
}
+
void randomArrayServicePort(Dart_NativeArguments arguments) {
Dart_EnterScope();
Dart_SetReturnValue(arguments, Dart_Null());
@@ -115,18 +133,24 @@
Dart_NativeFunction function;
};
+
FunctionLookup function_list[] = {
{"SystemRand", SystemRand},
{"SystemSrand", SystemSrand},
{"RandomArray_ServicePort", randomArrayServicePort},
{NULL, NULL}};
+
Dart_NativeFunction ResolveName(Dart_Handle name,
int argc,
bool* auto_setup_scope) {
- if (!Dart_IsString(name)) return NULL;
+ if (!Dart_IsString(name)) {
+ return NULL;
+ }
Dart_NativeFunction result = NULL;
- if (auto_setup_scope == NULL) return NULL;
+ if (auto_setup_scope == NULL) {
+ return NULL;
+ }
*auto_setup_scope = true;
Dart_EnterScope();
const char* cname;

Powered by Google App Engine
This is Rietveld 408576698