OLD | NEW |
(Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 #ifndef EMBEDDERS_OPENGLUI_COMMON_VM_GLUE_H_ |
| 6 #define EMBEDDERS_OPENGLUI_COMMON_VM_GLUE_H_ |
| 7 |
| 8 #include <stdlib.h> |
| 9 |
| 10 #include "embedders/openglui/common/events.h" |
| 11 #include "embedders/openglui/common/isized.h" |
| 12 #include "include/dart_api.h" |
| 13 |
| 14 class VMGlue { |
| 15 public: |
| 16 explicit VMGlue(ISized* surface, |
| 17 const char* script_path, |
| 18 const char* extension_script = NULL, |
| 19 const char* main_script = NULL); |
| 20 ~VMGlue() { |
| 21 delete[] main_script_; |
| 22 delete[] extension_script_; |
| 23 } |
| 24 |
| 25 int InitializeVM(); |
| 26 int StartMainIsolate(); |
| 27 int CallSetup(); |
| 28 int CallUpdate(); |
| 29 int OnMotionEvent(const char* funtion, int64_t when, |
| 30 float move_x, float move_y); |
| 31 int OnKeyEvent(const char* funtion, int64_t when, int32_t flags, |
| 32 int32_t key_code, int32_t meta_state, int32_t repeat); |
| 33 void FinishMainIsolate(); |
| 34 |
| 35 private: |
| 36 int Invoke(const char *function, int argc, Dart_Handle* args, |
| 37 bool failIfNotDefined = true); |
| 38 |
| 39 static int ErrorExit(const char* format, ...); |
| 40 static Dart_Handle CheckError(Dart_Handle); |
| 41 |
| 42 static bool CreateIsolateAndSetupHelper(const char* script_uri, |
| 43 const char* main, |
| 44 void* data, |
| 45 char** error); |
| 46 static bool CreateIsolateAndSetup(const char* script_uri, |
| 47 const char* main, |
| 48 void* data, char** error); |
| 49 static Dart_Handle LibraryTagHandler(Dart_LibraryTag tag, |
| 50 Dart_Handle library, |
| 51 Dart_Handle urlHandle); |
| 52 static Dart_Handle LoadSourceFromFile(const char* url); |
| 53 static void ShutdownIsolate(void* callback_data); |
| 54 |
| 55 ISized* surface_; |
| 56 Dart_Isolate isolate_; |
| 57 bool initialized_vm_; |
| 58 bool initialized_script_; |
| 59 char* main_script_; |
| 60 static char* extension_script_; |
| 61 }; |
| 62 |
| 63 #endif // EMBEDDERS_OPENGLUI_COMMON_VM_GLUE_H_ |
| 64 |
OLD | NEW |