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

Side by Side Diff: runtime/embedders/android/vm_glue.cc

Issue 11467028: Migrate files to embedder. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review fixes Created 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/embedders/android/vm_glue.h ('k') | samples/android_sample/android_sample.gyp » ('j') | 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 4
5 #include <math.h> 5 #include <math.h>
6 #include <stdio.h> 6 #include <stdio.h>
7 #include <unistd.h> 7 #include <unistd.h>
8 #include <sys/stat.h> 8 #include <sys/stat.h>
9 9
10 #include "include/dart_api.h" 10 #include "include/dart_api.h"
11 #include "jni/android_extension.h" 11 #include "embedders/android/android_extension.h"
12 #include "jni/log.h" 12 #include "embedders/android/log.h"
13 #include "jni/vm_glue.h" 13 #include "embedders/android/vm_glue.h"
14 14
15 // snapshot_buffer points to a snapshot if we link in a snapshot otherwise 15 // snapshot_buffer points to a snapshot if we link in a snapshot otherwise
16 // it is initialized to NULL. 16 // it is initialized to NULL.
17 17
18 VMGlue::VMGlue(Graphics* graphics) 18 VMGlue::VMGlue(Graphics* graphics)
19 : graphics_(graphics), 19 : graphics_(graphics),
20 isolate_(NULL), 20 isolate_(NULL),
21 initialized_vm_(false), 21 initialized_vm_(false),
22 initialized_script_(false) { 22 initialized_script_(false) {
23 LOGI("Creating VMGlue"); 23 LOGI("Creating VMGlue");
(...skipping 21 matching lines...) Expand all
45 #define CHECK_RESULT(result) \ 45 #define CHECK_RESULT(result) \
46 if (Dart_IsError(result)) { \ 46 if (Dart_IsError(result)) { \
47 *error = strdup(Dart_GetError(result)); \ 47 *error = strdup(Dart_GetError(result)); \
48 LOGE(*error); \ 48 LOGE(*error); \
49 Dart_ExitScope(); \ 49 Dart_ExitScope(); \
50 Dart_ShutdownIsolate(); \ 50 Dart_ShutdownIsolate(); \
51 return false; \ 51 return false; \
52 } 52 }
53 53
54 Dart_Handle VMGlue::LibraryTagHandler(Dart_LibraryTag tag, 54 Dart_Handle VMGlue::LibraryTagHandler(Dart_LibraryTag tag,
55 » » » » Dart_Handle library, 55 Dart_Handle library,
56 » » » » Dart_Handle urlHandle) { 56 Dart_Handle urlHandle) {
57 const char* url; 57 const char* url;
58 Dart_StringToCString(urlHandle, &url); 58 Dart_StringToCString(urlHandle, &url);
59 if (tag == kCanonicalizeUrl) { 59 if (tag == kCanonicalizeUrl) {
60 return urlHandle; 60 return urlHandle;
61 } 61 }
62 // TODO(vsm): Split this up into separate libraries for 3D, 2D, 62 // TODO(vsm): Split this up into separate libraries for 3D, 2D,
63 // Touch, Audio, etc. All builtin libraries should be handled here 63 // Touch, Audio, etc. All builtin libraries should be handled here
64 // (or moved into a snapshot). 64 // (or moved into a snapshot).
65 if (strcmp(url, "android_extension.dart") == 0) { 65 if (strcmp(url, "android_extension.dart") == 0) {
66 Dart_Handle source = VMGlue::LoadSourceFromFile("/data/data/com.google.dartn dk/app_dart/android_extension.dart"); 66 Dart_Handle source =
67 VMGlue::LoadSourceFromFile("/data/data/com.google.dartndk/app_dart/andro id_extension.dart");
67 Dart_Handle library = CheckError(Dart_LoadLibrary(urlHandle, source)); 68 Dart_Handle library = CheckError(Dart_LoadLibrary(urlHandle, source));
68 CheckError(Dart_SetNativeResolver(library, ResolveName)); 69 CheckError(Dart_SetNativeResolver(library, ResolveName));
69 return library; 70 return library;
70 } 71 }
71 LOGE("UNIMPLEMENTED: load library %s\n", url); 72 LOGE("UNIMPLEMENTED: load library %s\n", url);
72 return NULL; 73 return NULL;
73 } 74 }
74 75
75 // Returns true on success, false on failure. 76 // Returns true on success, false on failure.
76 bool VMGlue::CreateIsolateAndSetupHelper(const char* script_uri, 77 bool VMGlue::CreateIsolateAndSetupHelper(const char* script_uri,
77 const char* main, 78 const char* main,
78 void* data, 79 void* data,
79 char** error) { 80 char** error) {
80 LOGI("Creating isolate %s, %s", script_uri, main); 81 LOGI("Creating isolate %s, %s", script_uri, main);
81 Dart_Isolate isolate = 82 Dart_Isolate isolate =
82 Dart_CreateIsolate(script_uri, main, NULL, data, error); 83 Dart_CreateIsolate(script_uri, main, NULL, data, error);
83 if (isolate == NULL) { 84 if (isolate == NULL) {
84 LOGE("Couldn't create isolate: %s", error); 85 LOGE("Couldn't create isolate: %s", *error);
85 return false; 86 return false;
86 } 87 }
87 88
88 LOGI("Entering scope"); 89 LOGI("Entering scope");
89 Dart_EnterScope(); 90 Dart_EnterScope();
90 91
91 // Set up the library tag handler for this isolate. 92 // Set up the library tag handler for this isolate.
92 LOGI("Setting up library tag handler"); 93 LOGI("Setting up library tag handler");
93 Dart_Handle result = CheckError(Dart_SetLibraryTagHandler(LibraryTagHandler)); 94 Dart_Handle result = CheckError(Dart_SetLibraryTagHandler(LibraryTagHandler));
94 CHECK_RESULT(result); 95 CHECK_RESULT(result);
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 270
270 // Lookup the library of the root script. 271 // Lookup the library of the root script.
271 LOGI("looking up the root library"); 272 LOGI("looking up the root library");
272 Dart_Handle library = Dart_RootLibrary(); 273 Dart_Handle library = Dart_RootLibrary();
273 if (Dart_IsNull(library)) { 274 if (Dart_IsNull(library)) {
274 return ErrorExit("Unable to find root library\n"); 275 return ErrorExit("Unable to find root library\n");
275 } 276 }
276 277
277 // Lookup and invoke the appropriate function. 278 // Lookup and invoke the appropriate function.
278 LOGI("invoking %s", function); 279 LOGI("invoking %s", function);
279 result = Dart_Invoke(library, Dart_NewStringFromCString(function), argc, args) ; 280 result =
281 Dart_Invoke(library, Dart_NewStringFromCString(function), argc, args);
280 282
281 if (Dart_IsError(result)) { 283 if (Dart_IsError(result)) {
282 return ErrorExit("%s\n", Dart_GetError(result)); 284 return ErrorExit("%s\n", Dart_GetError(result));
283 } 285 }
284 286
285 // TODO(vsm): I don't think we need this. 287 // TODO(vsm): I don't think we need this.
286 // Keep handling messages until the last active receive port is closed. 288 // Keep handling messages until the last active receive port is closed.
287 LOGI("Entering Dart message loop"); 289 LOGI("Entering Dart message loop");
288 result = Dart_RunLoop(); 290 result = Dart_RunLoop();
289 if (Dart_IsError(result)) { 291 if (Dart_IsError(result)) {
290 return ErrorExit("%s\n", Dart_GetError(result)); 292 return ErrorExit("%s\n", Dart_GetError(result));
291 } 293 }
292 294
293 LOGI("out invoke"); 295 LOGI("out invoke");
294 return 0; 296 return 0;
295 } 297 }
296 298
297 void VMGlue::FinishMainIsolate() { 299 void VMGlue::FinishMainIsolate() {
298 LOGI("Finish main isolate"); 300 LOGI("Finish main isolate");
299 Dart_EnterIsolate(isolate_); 301 Dart_EnterIsolate(isolate_);
300 // Shutdown the isolate. 302 // Shutdown the isolate.
301 Dart_ShutdownIsolate(); 303 Dart_ShutdownIsolate();
302 isolate_ = NULL; 304 isolate_ = NULL;
303 initialized_script_ = false; 305 initialized_script_ = false;
304 } 306 }
OLDNEW
« no previous file with comments | « runtime/embedders/android/vm_glue.h ('k') | samples/android_sample/android_sample.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698