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

Unified Diff: utils/archive/messaging.c

Issue 10832116: Attach the native entry struct to the ArchiveEntry object. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 5 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: utils/archive/messaging.c
diff --git a/utils/archive/messaging.c b/utils/archive/messaging.c
index 6a1c97dbd8400909c756c99858c28f42470226ef..6d90df02b6803e0bdb10d1d370e4d4b40ebb4ebe 100644
--- a/utils/archive/messaging.c
+++ b/utils/archive/messaging.c
@@ -58,6 +58,15 @@ bool checkError(Dart_Port p, struct archive* a, int result) {
postError(p, a);
}
+bool checkPointerError(Dart_Port p, void* pointer, char* name) {
+ if (pointer != NULL) return false;
+ char buffer[100];
+ snprintf(buffer, 100, "Failed to allocate memory for %s.", name);
+ DART_STRING(error_string, buffer);
+ postResult(p, false, ENOMEM, &error_string);
+ return true;
+}
+
bool checkType(Dart_Port p, Dart_CObject* object, enum Type type) {
if (object->type == type) return false;
postInvalidArgument(p, "Invalid argument: expected type %d, was type %d.",
@@ -70,6 +79,12 @@ void checkResult(Dart_Port p, struct archive* a, int result) {
postSuccess(p, NULL);
}
+void checkPointerResult(Dart_Port p, void* pointer, char* name) {
+ if (checkPointerError(p, pointer, name)) return;
+ DART_INT64(result, (intptr_t) pointer);
+ postSuccess(p, &result);
+}
+
Dart_CObject* getArgument(Dart_Port p, Dart_CObject* request, int i) {
if (checkType(p, request, kArray)) return NULL;
@@ -106,3 +121,20 @@ int64_t getInteger(Dart_CObject* object) {
if (object->type == kInt64) return object->value.as_int64;
if (object->type == kInt32) return (int64_t) object->value.as_int32;
}
+
+Dart_CObject* getNullableStringArgument(Dart_Port p, Dart_CObject* request,
+ int i) {
+ Dart_CObject* arg = getArgument(p, request, i);
+ if (arg == NULL) return NULL;
+ if (arg->type == kNull) return arg;
+ if (arg->type == kString) return arg;
+ postInvalidArgument(p, "Invalid argument %d: expected string or null, was " \
+ "type %d.", i+1, arg->type);
+ return NULL;
+}
+
+char* getNullableString(Dart_CObject* object) {
+ assert(object->type == kNull || object->type == kString);
+ if (object->type == kString) return object->value.as_string;
+ return NULL;
+}

Powered by Google App Engine
This is Rietveld 408576698