コード例 #1
0
void Fl_Cairo_Window_Wrapper::draw_cb(Fl_Cairo_Window *self, cairo_t *ctx) {
  Dart_PersistentHandle *ref = (Dart_PersistentHandle*)self -> user_data();

  // Create instance of CairoContext.
  Dart_Handle dartCairoContextType = HandleError(Dart_GetType(
                                       Dart_LookupLibrary(
                                         Dart_NewStringFromCString("package:fltk/fltk.dart")),
                                       Dart_NewStringFromCString("CairoContext"), 0, {}));
  Dart_Handle dartCairoContext = Dart_New(
                                   dartCairoContextType, Dart_EmptyString(), 0, {});

  // Link cairo context to CairoContext.
  Dart_SetNativeInstanceField(dartCairoContext, 0, (intptr_t)ctx);

  Dart_Handle args[1] = { dartCairoContext };
  HandleError(Dart_Invoke(*ref, Dart_NewStringFromCString("runDrawCb"), 1, args));
}
コード例 #2
0
ファイル: TextBox.cpp プロジェクト: algor/engine
Dart_Handle DartConverter<TextBox>::ToDart(const TextBox& val) {
  if (val.is_null)
    return Dart_Null();
  DartClassLibrary& class_library = DartState::Current()->class_library();
  Dart_Handle type = Dart_HandleFromPersistent(
      class_library.GetClass("ui", "TextBox"));
  DCHECK(!LogIfError(type));
  const int argc = 5;
  Dart_Handle argv[argc] = {
    blink::ToDart(val.sk_rect.fLeft),
    blink::ToDart(val.sk_rect.fTop),
    blink::ToDart(val.sk_rect.fRight),
    blink::ToDart(val.sk_rect.fBottom),
    blink::ToDart(static_cast<int>(val.direction)),
  };
  return Dart_New(type, blink::ToDart("_"), argc, argv);
}
コード例 #3
0
ファイル: Isolate.cpp プロジェクト: field/ofxFieldKitDart
    Dart_Handle Isolate::New(const char* typeName, int argc, Dart_Handle* args)
    {
        // entering and leaving the scope here causes us to invalidate the instance handle!
//        Dart_EnterScope();
        
        // Get type
        Dart_Handle type = Dart_GetType(library_, NewString(typeName), 0, NULL);
        if(Dart_IsError(type)) {
            LOG_E(Dart_GetError(type));
        }
        
        // Invoke the unnamed constructor.
        Dart_Handle instance = Dart_New(type, Dart_Null(), argc, args);
        
        if (Dart_IsError(instance)) {
            //            Dart_NewApiError
            LOG_E(Dart_GetError(instance) << " while instantiating '"<< type <<"'")
        }

//        Dart_ExitScope();
        return instance;
    }