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

Side by Side Diff: sky/engine/bindings-dart/dart_master.cpp

Issue 894753002: Rename dart_master.cpp to .cc, consistent with chromium style (Closed) Base URL: https://github.com/eseidel/skydart.git@master
Patch Set: Created 5 years, 10 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
« no previous file with comments | « sky/engine/bindings-dart/dart_master.cc ('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
(Empty)
1 #include "sky/engine/config.h"
2 #include "sky/engine/bindings-dart/dart_master.h"
3
4 #include "base/logging.h"
5
6 namespace mojo {
7 namespace dart {
8
9 extern const uint8_t* snapshot_buffer;
10 }
11 }
12
13 namespace blink {
14
15 static Dart_Isolate IsolateCreateCallback(const char* script_uri,
16 const char* main,
17 const char* package_root,
18 void* callback_data,
19 char** error) {
20 // LOG(INFO) << "IsolateCreateCallback";
21 return nullptr;
22 }
23
24 static void UnhandledExceptionCallback(Dart_Handle error) {
25 // LOG(INFO) << "UnhandledExceptionCallback";
26 }
27
28 static void IsolateShutdownCallback(void* callback_data) {
29 // LOG(INFO) << "IsolateShutdownCallback";
30 }
31
32 static Dart_Isolate ServiceIsolateCreateCallback(void* callback_data,
33 char** error) {
34 // LOG(INFO) << "ServiceIsolateCreateCallback";
35 return nullptr;
36 }
37
38 void DartMaster::InitVM() {
39 bool result = Dart_SetVMFlags(0, NULL);
40
41 result = Dart_Initialize(IsolateCreateCallback,
42 nullptr, // Isolate interrupt callback.
43 UnhandledExceptionCallback, IsolateShutdownCallback,
44 // File IO callbacks.
45 nullptr, nullptr, nullptr, nullptr, nullptr,
46 ServiceIsolateCreateCallback);
47
48 char* error;
49 Dart_Isolate isolate = Dart_CreateIsolate(
50 "bogus:uri", "main", mojo::dart::snapshot_buffer, nullptr, &error);
51
52 CHECK(isolate);
53
54 Dart_EnterScope();
55
56 Dart_Handle library = Dart_LoadLibrary(
57 Dart_NewStringFromCString("foo:bar"),
58 Dart_NewStringFromCString("main() { int foo = 2; foo++; return foo; }"),
59 0, 0);
60
61 Dart_FinalizeLoading(true);
62
63 if (Dart_IsError(library)) {
64 LOG(INFO) << Dart_GetError(library);
65 abort();
66 }
67
68 Dart_Handle invoke_result =
69 Dart_Invoke(library, Dart_NewStringFromCString("main"), 0, nullptr);
70 if (Dart_IsError(invoke_result)) {
71 LOG(INFO) << Dart_GetError(invoke_result);
72 abort();
73 }
74
75 CHECK(Dart_IsInteger(invoke_result));
76 Dart_Handle str = Dart_ToString(invoke_result);
77 const char* xyz = "invalid";
78 Dart_StringToCString(str, &xyz);
79 LOG(INFO) << xyz;
80 }
81 }
OLDNEW
« no previous file with comments | « sky/engine/bindings-dart/dart_master.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698