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));
}
Beispiel #2
0
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);
}
Beispiel #3
0
    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;
    }