{"action":"created","comment":{"url":"https://api.github.com/repos/briskml/brisk/pulls/comments/217882127","pull_request_review_id":155710591,"id":217882127,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIxNzg4MjEyNw==","diff_hunk":"@@ -0,0 +1,780 @@\n+#include <Cocoa/Cocoa.h>\n+\n+#define CAML_NAME_SPACE\n+\n+#include <caml/mlvalues.h>\n+#include <caml/memory.h>\n+#include <caml/callback.h>\n+#include <caml/alloc.h>\n+#include <caml/bigarray.h>\n+#include <caml/custom.h>\n+#include <caml/fail.h>\n+#include <caml/threads.h>\n+\n+#define Val_NSApplication(v) ((value)(v))\n+#define NSApplication_val(v) ((__bridge NSApplication *)(value)(v))\n+\n+#define Val_NSWindow(v) ((value)(v))\n+#define NSWindow_val(v) ((__bridge NSWindow *)(value)(v))\n+\n+@interface View : NSView\n+@end\n+\n+@implementation View\n+\n+- (BOOL)isFlipped\n+{\n+  return YES;\n+}\n+\n+@end\n+\n+typedef void (^ActionBlock)();\n+\n+@interface Button : NSButton\n+\n+@property(nonatomic, copy) ActionBlock _actionBlock;\n+\n+- (void)onClick:(ActionBlock)action;\n+@end\n+\n+@implementation Button\n+\n+- (void)onClick:(ActionBlock)action\n+{\n+  self._actionBlock = action;\n+  [self setTarget:self];\n+  [self setAction:@selector(callActionBlock:)];\n+}\n+\n+- (void)callActionBlock:(id)sender\n+{\n+  NSLog(@\"sending\");\n+#pragma unused(sender)\n+  self._actionBlock();\n+}\n+@end\n+\n+#define Val_View(v) ((value)(v))\n+#define View_val(v) ((__bridge View *)(value)(v))\n+\n+#define Val_Button(v) ((value)(v))\n+#define Button_val(v) ((__bridge Button *)(value)(v))\n+\n+static NSMutableDictionary *ml_Views;\n+static NSMutableArray *ml_Views_all;\n+// static NSMutableArray *ml_Callbacks_all;\n+dispatch_queue_t ml_q;\n+\n+CAMLprim value ml_NSLog(value str)\n+{\n+  CAMLparam1(str);\n+  NSLog(@\"%s\", String_val(str));\n+  CAMLreturn(Val_unit);\n+}\n+\n+@interface MLApplicationDelegate : NSObject <NSApplicationDelegate>\n+\n+- (void)makeMainMenu;\n+\n+- (void)makeApplicationMenu:(NSMenu *)aMenu;\n+- (void)makeEditMenu:(NSMenu *)aMenu;\n+- (void)makeFileMenu:(NSMenu *)aMenu;\n+- (void)makeFindMenu:(NSMenu *)aMenu;\n+- (void)makeHelpMenu:(NSMenu *)aMenu;\n+- (void)makeSpellingMenu:(NSMenu *)aMenu;\n+- (void)makeWindowMenu:(NSMenu *)aMenu;\n+\n+@end\n+\n+enum\n+{\n+  ApplicationWillFinishLaunching,\n+  ApplicationDidFinishLaunching\n+};\n+\n+@implementation MLApplicationDelegate\n+{\n+  value applicationId;\n+}\n+\n+- (instancetype)initWithId:(value)appId\n+{\n+  if (self = [super init])\n+  {\n+    applicationId = appId;\n+  }\n+  ml_Views = [NSMutableDictionary new];\n+  ml_Views_all = [NSMutableArray new];\n+  return self;\n+}\n+\n+- (void)applicationWillTerminate:(NSNotification *)__unused not\n+{\n+  // Insert code here to tear down your application\n+}\n+\n+- (void)applicationWillFinishLaunching:(NSNotification *)__unused not\n+{\n+  static value *closure_f = NULL;\n+\n+  [self makeMainMenu];\n+\n+  if (closure_f == NULL)\n+  {\n+    closure_f = caml_named_value(\"NSApp.delegate\");\n+  }\n+\n+  if (closure_f != NULL)\n+  {\n+    caml_callback2(*closure_f, applicationId, Val_int(ApplicationWillFinishLaunching));\n+  }\n+}\n+\n+- (void)applicationDidFinishLaunching:(NSNotification *)__unused not\n+{\n+  // ml_q = dispatch_queue_create(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);\n+\n+  static value *closure_f = NULL;\n+\n+  if (closure_f == NULL)\n+  {\n+    closure_f = caml_named_value(\"NSApp.delegate\");\n+  }\n+\n+  if (closure_f != NULL)\n+  {\n+    caml_callback2(*closure_f, applicationId, Val_int(ApplicationDidFinishLaunching));\n+  }\n+}\n+\n+- (void)makeMainMenu\n+{\n+  NSMenu *mainMenu = [[NSMenu alloc] initWithTitle:@\"MainMenu\"];\n+\n+  NSMenuItem *menuItem;\n+  NSMenu *submenu;\n+\n+  // The titles of the menu items are for identification purposes only and shouldn't be localized.\n+  // The strings in the menu bar come from the submenu titles,\n+  // except for the application menu, whose title is ignored at runtime.\n+  menuItem = [mainMenu addItemWithTitle:@\"Apple\" action:NULL keyEquivalent:@\"\"];\n+  submenu = [[NSMenu alloc] initWithTitle:@\"Apple\"];\n+  [NSApp performSelector:@selector(setAppleMenu:) withObject:submenu];\n+  [self makeApplicationMenu:submenu];\n+  [mainMenu setSubmenu:submenu forItem:menuItem];\n+\n+  menuItem = [mainMenu addItemWithTitle:@\"File\" action:NULL keyEquivalent:@\"\"];\n+  submenu = [[NSMenu alloc] initWithTitle:@\"File\"];\n+  [self makeFileMenu:submenu];\n+  [mainMenu setSubmenu:submenu forItem:menuItem];\n+\n+  menuItem = [mainMenu addItemWithTitle:@\"Edit\" action:NULL keyEquivalent:@\"\"];\n+  submenu = [[NSMenu alloc] initWithTitle:@\"Edit\"];\n+  [self makeEditMenu:submenu];\n+  [mainMenu setSubmenu:submenu forItem:menuItem];\n+\n+  menuItem = [mainMenu addItemWithTitle:@\"Window\" action:NULL keyEquivalent:@\"\"];\n+  submenu = [[NSMenu alloc] initWithTitle:@\"Window\"];\n+  [self makeWindowMenu:submenu];\n+  [mainMenu setSubmenu:submenu forItem:menuItem];\n+  [NSApp setWindowsMenu:submenu];\n+\n+  menuItem = [mainMenu addItemWithTitle:@\"Help\" action:NULL keyEquivalent:@\"\"];\n+  submenu = [[NSMenu alloc] initWithTitle:@\"Help\"];\n+  [self makeHelpMenu:submenu];\n+  [mainMenu setSubmenu:submenu forItem:menuItem];\n+\n+  [NSApp setMainMenu:mainMenu];\n+}\n+\n+- (void)makeApplicationMenu:(NSMenu *)aMenu\n+{\n+  NSString *applicationName = @\"BriskMac\";\n+  NSMenuItem *menuItem;\n+\n+  menuItem = [aMenu addItemWithTitle:[NSString stringWithFormat:@\"%@ %@\", @\"About\", applicationName]\n+                              action:@selector(orderFrontStandardAboutPanel:)\n+                       keyEquivalent:@\"\"];\n+  [menuItem setTarget:NSApp];\n+\n+  [aMenu addItem:[NSMenuItem separatorItem]];\n+\n+  menuItem = [aMenu addItemWithTitle:@\"Preferences...\"\n+                              action:NULL\n+                       keyEquivalent:@\",\"];\n+\n+  [aMenu addItem:[NSMenuItem separatorItem]];\n+\n+  menuItem = [aMenu addItemWithTitle:@\"Services\"\n+                              action:NULL\n+                       keyEquivalent:@\"\"];\n+  NSMenu *servicesMenu = [[NSMenu alloc] initWithTitle:@\"Services\"];\n+  [aMenu setSubmenu:servicesMenu forItem:menuItem];\n+  [NSApp setServicesMenu:servicesMenu];\n+\n+  [aMenu addItem:[NSMenuItem separatorItem]];\n+\n+  menuItem = [aMenu addItemWithTitle:[NSString stringWithFormat:@\"%@ %@\", @\"Hide\", applicationName]\n+                              action:@selector(hide:)\n+                       keyEquivalent:@\"h\"];\n+  [menuItem setTarget:NSApp];\n+\n+  menuItem = [aMenu addItemWithTitle:@\"Hide Others\"\n+                              action:@selector(hideOtherApplications:)\n+                       keyEquivalent:@\"h\"];\n+  [menuItem setKeyEquivalentModifierMask:NSEventModifierFlagCommand | NSEventModifierFlagOption];\n+  [menuItem setTarget:NSApp];\n+\n+  menuItem = [aMenu addItemWithTitle:@\"Show All\"\n+                              action:@selector(unhideAllApplications:)\n+                       keyEquivalent:@\"\"];\n+  [menuItem setTarget:NSApp];\n+\n+  [aMenu addItem:[NSMenuItem separatorItem]];\n+\n+  menuItem = [aMenu addItemWithTitle:[NSString stringWithFormat:@\"%@ %@\", @\"Quit\", applicationName]\n+                              action:@selector(terminate:)\n+                       keyEquivalent:@\"q\"];\n+  [menuItem setTarget:NSApp];\n+}\n+\n+- (void)makeEditMenu:(NSMenu *)aMenu\n+{\n+  NSMenuItem *menuItem;\n+\n+  menuItem = [aMenu addItemWithTitle:@\"Undo\"\n+                              action:@selector(undo:)\n+                       keyEquivalent:@\"z\"];\n+\n+  menuItem = [aMenu addItemWithTitle:@\"Redo\"\n+                              action:@selector(redo:)\n+                       keyEquivalent:@\"Z\"];\n+\n+  [aMenu addItem:[NSMenuItem separatorItem]];\n+\n+  menuItem = [aMenu addItemWithTitle:@\"Cut\"\n+                              action:@selector(cut:)\n+                       keyEquivalent:@\"x\"];\n+\n+  menuItem = [aMenu addItemWithTitle:@\"Copy\"\n+                              action:@selector(copy:)\n+                       keyEquivalent:@\"c\"];\n+\n+  menuItem = [aMenu addItemWithTitle:@\"Paste\"\n+                              action:@selector(paste:)\n+                       keyEquivalent:@\"v\"];\n+\n+  menuItem = [aMenu addItemWithTitle:@\"Paste and Match Style\"\n+                              action:@selector(pasteAsPlainText:)\n+                       keyEquivalent:@\"V\"];\n+  [menuItem setKeyEquivalentModifierMask:NSEventModifierFlagCommand | NSEventModifierFlagOption];\n+\n+  menuItem = [aMenu addItemWithTitle:@\"Delete\"\n+                              action:@selector(delete:)\n+                       keyEquivalent:@\"\"];\n+\n+  menuItem = [aMenu addItemWithTitle:@\"Select All\"\n+                              action:@selector(selectAll:)\n+                       keyEquivalent:@\"a\"];\n+\n+  [aMenu addItem:[NSMenuItem separatorItem]];\n+\n+  menuItem = [aMenu addItemWithTitle:@\"Find\"\n+                              action:NULL\n+                       keyEquivalent:@\"\"];\n+  NSMenu *findMenu = [[NSMenu alloc] initWithTitle:@\"Find\"];\n+  [self makeFindMenu:findMenu];\n+  [aMenu setSubmenu:findMenu forItem:menuItem];\n+\n+  menuItem = [aMenu addItemWithTitle:@\"Spelling\"\n+                              action:NULL\n+                       keyEquivalent:@\"\"];\n+  NSMenu *spellingMenu = [[NSMenu alloc] initWithTitle:@\"Spelling\"];\n+  [self makeSpellingMenu:spellingMenu];\n+  [aMenu setSubmenu:spellingMenu forItem:menuItem];\n+}\n+\n+- (void)makeFileMenu:(NSMenu *)aMenu\n+{\n+  NSMenuItem *menuItem;\n+\n+  menuItem = [aMenu addItemWithTitle:@\"New\"\n+                              action:NULL\n+                       keyEquivalent:@\"n\"];\n+\n+  menuItem = [aMenu addItemWithTitle:@\"Open...\"\n+                              action:NULL\n+                       keyEquivalent:@\"o\"];\n+\n+  menuItem = [aMenu addItemWithTitle:@\"Open Recent\"\n+                              action:NULL\n+                       keyEquivalent:@\"\"];\n+  NSMenu *openRecentMenu = [[NSMenu alloc] initWithTitle:@\"Open Recent\"];\n+  [openRecentMenu performSelector:@selector(_setMenuName:) withObject:@\"NSRecentDocumentsMenu\"];\n+  [aMenu setSubmenu:openRecentMenu forItem:menuItem];\n+\n+  menuItem = [openRecentMenu addItemWithTitle:@\"Clear Menu\"\n+                                       action:@selector(clearRecentDocuments:)\n+                                keyEquivalent:@\"\"];\n+\n+  [aMenu addItem:[NSMenuItem separatorItem]];\n+\n+  menuItem = [aMenu addItemWithTitle:@\"Close\"\n+                              action:@selector(performClose:)\n+                       keyEquivalent:@\"w\"];\n+\n+  menuItem = [aMenu addItemWithTitle:@\"Save\"\n+                              action:NULL\n+                       keyEquivalent:@\"s\"];\n+\n+  menuItem = [aMenu addItemWithTitle:@\"Save As...\"\n+                              action:NULL\n+                       keyEquivalent:@\"S\"];\n+\n+  menuItem = [aMenu addItemWithTitle:@\"Revert\"\n+                              action:NULL\n+                       keyEquivalent:@\"\"];\n+\n+  [aMenu addItem:[NSMenuItem separatorItem]];\n+\n+  menuItem = [aMenu addItemWithTitle:@\"Page Setup...\"\n+                              action:@selector(runPageLayout:)\n+                       keyEquivalent:@\"P\"];\n+\n+  menuItem = [aMenu addItemWithTitle:@\"Print...\"\n+                              action:@selector(print:)\n+                       keyEquivalent:@\"p\"];\n+}\n+\n+- (void)makeFindMenu:(NSMenu *)aMenu\n+{\n+  NSMenuItem *menuItem;\n+\n+  menuItem = [aMenu addItemWithTitle:@\"Find...\"\n+                              action:@selector(performFindPanelAction:)\n+                       keyEquivalent:@\"f\"];\n+  [menuItem setTag:NSFindPanelActionShowFindPanel];\n+\n+  menuItem = [aMenu addItemWithTitle:@\"Find Next\"\n+                              action:@selector(performFindPanelAction:)\n+                       keyEquivalent:@\"g\"];\n+  [menuItem setTag:NSFindPanelActionNext];\n+\n+  menuItem = [aMenu addItemWithTitle:@\"Find Previous\"\n+                              action:@selector(performFindPanelAction:)\n+                       keyEquivalent:@\"G\"];\n+  [menuItem setTag:NSFindPanelActionPrevious];\n+\n+  menuItem = [aMenu addItemWithTitle:@\"Use Selection for Find\"\n+                              action:@selector(performFindPanelAction:)\n+                       keyEquivalent:@\"e\"];\n+  [menuItem setTag:NSFindPanelActionSetFindString];\n+\n+  menuItem = [aMenu addItemWithTitle:@\"Jump to Selection\"\n+                              action:@selector(centerSelectionInVisibleArea:)\n+                       keyEquivalent:@\"j\"];\n+}\n+\n+- (void)makeHelpMenu:(NSMenu *)aMenu\n+{\n+  NSMenuItem *menuItem;\n+\n+  menuItem = [aMenu addItemWithTitle:[NSString stringWithFormat:@\"%@ %@\", @\"BriskMac\", @\"Help\"]\n+                              action:@selector(showHelp:)\n+                       keyEquivalent:@\"?\"];\n+  [menuItem setTarget:NSApp];\n+}\n+\n+- (void)makeSpellingMenu:(NSMenu *)aMenu\n+{\n+  NSMenuItem *menuItem;\n+\n+  menuItem = [aMenu addItemWithTitle:@\"Spelling...\"\n+                              action:@selector(showGuessPanel:)\n+                       keyEquivalent:@\":\"];\n+\n+  menuItem = [aMenu addItemWithTitle:@\"Check Spelling\"\n+                              action:@selector(checkSpelling:)\n+                       keyEquivalent:@\";\"];\n+\n+  menuItem = [aMenu addItemWithTitle:@\"Check Spelling as You Type\"\n+                              action:@selector(toggleContinuousSpellChecking:)\n+                       keyEquivalent:@\"\"];\n+}\n+\n+- (void)makeWindowMenu:(NSMenu *)aMenu\n+{\n+  NSMenuItem *menuItem;\n+\n+  menuItem = [aMenu addItemWithTitle:@\"Minimize\"\n+                              action:@selector(performMinimize:)\n+                       keyEquivalent:@\"m\"];\n+\n+  menuItem = [aMenu addItemWithTitle:@\"Zoom\"\n+                              action:@selector(performZoom:)\n+                       keyEquivalent:@\"\"];\n+\n+  [aMenu addItem:[NSMenuItem separatorItem]];\n+\n+  menuItem = [aMenu addItemWithTitle:@\"Bring All to Front\"\n+                              action:@selector(arrangeInFront:)\n+                       keyEquivalent:@\"\"];\n+}\n+\n+@end\n+\n+@interface MLWindowDelegate : NSObject <NSWindowDelegate>\n+\n+@end\n+\n+enum\n+{\n+  WindowDidResize\n+};\n+\n+@implementation MLWindowDelegate\n+{\n+  value windowId;\n+}\n+\n+- (instancetype)initWithId:(value)winId\n+{\n+  if (self = [super init])\n+  {\n+    windowId = winId;\n+  }\n+  return self;\n+}\n+\n+- (void)windowDidResize:(NSNotification *)__unused aNotification\n+{\n+  static value *closure_f = NULL;\n+\n+  if (closure_f == NULL)\n+  {\n+    closure_f = caml_named_value(\"NSWindow.delegate\");\n+  }\n+\n+  caml_callback2(*closure_f, windowId, Val_int(WindowDidResize));\n+}\n+\n+@end\n+\n+CAMLprim value ml_NSWindow_makeWithContentRect(value winId, value x_v, value y_v, value w_v, value h_v)\n+{\n+  CAMLparam5(winId, x_v, y_v, w_v, h_v);\n+  CGFloat x = Double_val(x_v);\n+  CGFloat y = Double_val(y_v);\n+  CGFloat w = Double_val(w_v);\n+  CGFloat h = Double_val(h_v);\n+\n+  NSRect contentRect = NSMakeRect(x, y, w, h);\n+\n+  NSUInteger styleMask =\n+      NSWindowStyleMaskTitled |\n+      NSWindowStyleMaskClosable |\n+      NSWindowStyleMaskMiniaturizable |\n+      NSWindowStyleMaskResizable;\n+\n+  NSWindow *win = [[NSWindow alloc] initWithContentRect:contentRect\n+                                              styleMask:styleMask\n+                                                backing:NSBackingStoreBuffered\n+                                                  defer:NO];\n+  [win setDelegate:[[MLWindowDelegate alloc] initWithId:winId]];\n+\n+  CAMLreturn(Val_NSWindow(win));\n+}\n+\n+CAMLprim value ml_NSWindow_center(value win_v)\n+{\n+  CAMLparam1(win_v);\n+  NSWindow *win = NSWindow_val(win_v);\n+  [win center];\n+  CAMLreturn(Val_unit);\n+}\n+\n+CAMLprim value ml_NSWindow_makeKeyAndOrderFront(value win_v)\n+{\n+  CAMLparam1(win_v);\n+  NSWindow *win = NSWindow_val(win_v);\n+  [win makeKeyAndOrderFront:nil];\n+\n+  CAMLreturn(Val_unit);\n+}\n+\n+CAMLprim value ml_NSWindow_isVisible(value win_v)\n+{\n+  CAMLparam1(win_v);\n+  NSWindow *win = NSWindow_val(win_v);\n+  BOOL b = [win isVisible];\n+\n+  CAMLreturn(Val_bool(b));\n+}\n+\n+CAMLprim value ml_NSWindow_contentView(value win_v)\n+{\n+  CAMLparam1(win_v);\n+  NSWindow *win = NSWindow_val(win_v);\n+\n+  CAMLreturn(Val_View(win.contentView));\n+}\n+\n+CAMLprim value ml_NSWindow_title(value win_v)\n+{\n+  CAMLparam1(win_v);\n+  CAMLlocal1(str_v);\n+\n+  NSWindow *win = NSWindow_val(win_v);\n+  NSString *str = [win title];\n+  const char *bytes = [str UTF8String];\n+  int len = strlen(bytes);\n+  str_v = caml_alloc_string(len);\n+  memcpy(String_val(str_v), bytes, len);\n+\n+  CAMLreturn(str_v);\n+}\n+\n+CAMLprim value ml_NSWindow_setContentView(value win_v, value view_v)\n+{\n+  CAMLparam1(win_v);\n+  NSWindow *win = NSWindow_val(win_v);\n+  View *view = View_val(view_v);\n+\n+  // [view setWantsLayer:YES];\n+\n+  [win setContentView:view];\n+\n+  CAMLreturn(Val_unit);\n+}\n+\n+CAMLprim value ml_NSWindow_setTitle(value win_v, value str_v)\n+{\n+  CAMLparam2(win_v, str_v);\n+  NSWindow *win = NSWindow_val(win_v);\n+  NSString *str = [NSString stringWithUTF8String:String_val(str_v)];\n+  [win setTitle:str];\n+\n+  CAMLreturn(Val_unit);\n+}\n+\n+CAMLprim value ml_NSApplication_NSApp(value appId)\n+{\n+  CAMLparam1(appId);\n+  NSApplication *app = [NSApplication sharedApplication];\n+  [app setActivationPolicy:NSApplicationActivationPolicyRegular];\n+  [app activateIgnoringOtherApps:YES];\n+  [app setDelegate:[[MLApplicationDelegate alloc] initWithId:appId]];\n+\n+  CAMLreturn(Val_NSApplication(app));\n+}\n+\n+CAMLprim value ml_NSApplication_run(value appId)\n+{\n+  CAMLparam1(appId);\n+\n+  @autoreleasepool\n+  {\n+    NSApplication *app = [NSApplication sharedApplication];\n+    [app run];\n+  }\n+\n+  CAMLreturn(Val_unit);\n+}\n+\n+// View\n+CAMLprim value ml_NSView_make()\n+{\n+  CAMLparam0();\n+\n+  View *view = nil;\n+  view = [View new];\n+\n+  [ml_Views_all addObject:view];\n+\n+  CAMLreturn(Val_View(view));\n+}\n+\n+CAMLprim value ml_NSView_memoize(value id_v, value view_v)\n+{\n+  CAMLparam2(id_v, view_v);\n+  View *view = View_val(view_v);\n+\n+  [ml_Views setObject:view forKey:@(Int_val(id_v))];\n+\n+  CAMLreturn(Val_unit);\n+}\n+\n+CAMLprim value ml_NSView_free(value id_v)\n+{\n+  CAMLparam1(id_v);\n+\n+  [ml_Views removeObjectForKey:@(Int_val(id_v))];\n+  CAMLreturn(Val_unit);\n+}\n+\n+CAMLprim value ml_NSView_addSubview(value view_v, value child_v)\n+{\n+  CAMLparam2(view_v, child_v);\n+  View *view = View_val(view_v);\n+  View *child = View_val(child_v);\n+\n+  [view addSubview:child];\n+\n+  CAMLreturn(Val_View(view));\n+}\n+\n+// CAMLprim value ml_NSView_insertSubviewAt(View *view, View *child, intnat pos_)\n+// {\n+//   [view addSubview:child];\n+//   [view insertSubview:child atIndex:pos_];\n+\n+//   CAMLreturn(Val_unit);\n+// }\n+\n+CAMLprim value ml_NSView_removeSubview(value child_v)\n+{\n+  CAMLparam1(child_v);\n+  View *child = View_val(child_v);\n+\n+  [child removeFromSuperview];\n+\n+  CAMLreturn(Val_unit);\n+}\n+\n+CAMLprim value ml_NSView_setFrame(value view_v, value x_v, value y_v, value w_v, value h_v)\n+{\n+  CAMLparam5(view_v, x_v, y_v, w_v, h_v);\n+\n+  View *view = View_val(view_v);\n+\n+  CGFloat x = Double_val(x_v);\n+  CGFloat y = Double_val(y_v);\n+  CGFloat w = Double_val(w_v);\n+  CGFloat h = Double_val(h_v);\n+\n+  NSRect rect = NSMakeRect(x, y, w, h);\n+  [view setFrame:rect];\n+\n+  CAMLreturn(Val_unit);\n+}\n+\n+CAMLprim value ml_NSView_setBorderWidth(value view_v, value width_v)\n+{\n+  CAMLparam2(view_v, width_v);\n+\n+  View *view = View_val(view_v);\n+\n+  [view.layer setBorderWidth:Int_val(width_v)];\n+\n+  CAMLreturn(Val_unit);\n+}\n+\n+CAMLprim value ml_NSView_setBorderColor(value view_v, value red_v, value green_v, value blue_v, value alpha_v)\n+{\n+  CAMLparam5(view_v, red_v, blue_v, green_v, alpha_v);\n+\n+  View *view = View_val(view_v);\n+\n+  CGFloat red = Double_val(red_v) / 255;\n+  CGFloat blue = Double_val(blue_v) / 255;\n+  CGFloat green = Double_val(green_v) / 255;\n+  CGFloat alpha = Double_val(alpha_v);\n+\n+  [view setWantsLayer:YES];\n+  [view.layer setBorderColor:[[NSColor colorWithRed:red green:green blue:blue alpha:alpha] CGColor]];\n+\n+  CAMLreturn(Val_unit);\n+}\n+\n+CAMLprim value ml_NSView_setBackgroundColor(value view_v, value red_v, value green_v, value blue_v, value alpha_v)\n+{\n+  CAMLparam5(view_v, red_v, blue_v, green_v, alpha_v);\n+\n+  View *view = View_val(view_v);\n+\n+  CGFloat red = Double_val(red_v) / 255;\n+  CGFloat blue = Double_val(blue_v) / 255;\n+  CGFloat green = Double_val(green_v) / 255;\n+  CGFloat alpha = Double_val(alpha_v);\n+\n+  [view setWantsLayer:YES];\n+  [view.layer setBackgroundColor:[[NSColor colorWithRed:red green:green blue:blue alpha:alpha] CGColor]];\n+\n+  CAMLreturn(Val_unit);\n+}\n+\n+// NSButton\n+CAMLprim value ml_NSButton_make()\n+{\n+  CAMLparam0();\n+\n+  Button *btn = nil;\n+  btn = [Button new];\n+  [ml_Views_all addObject:btn];\n+\n+  CAMLreturn(Val_Button(btn));\n+}\n+\n+CAMLprim value ml_NSButton_memoize(value id_v, value btn_v)\n+{\n+  CAMLparam2(id_v, btn_v);\n+  Button *btn = Button_val(btn_v);\n+\n+  [ml_Views setObject:btn forKey:@(Int_val(id_v))];\n+\n+  CAMLreturn(Val_unit);\n+}\n+\n+CAMLprim value ml_NSButton_free(value id_v)\n+{\n+  CAMLparam1(id_v);\n+\n+  [ml_Views removeObjectForKey:@(Int_val(id_v))];\n+  CAMLreturn(Val_unit);\n+}\n+\n+CAMLprim value ml_NSButton_setFrame(value btn_v, value x_v, value y_v, value w_v, value h_v)\n+{\n+  CAMLparam5(btn_v, x_v, y_v, w_v, h_v);\n+\n+  Button *btn = Button_val(btn_v);\n+\n+  CGFloat x = Double_val(x_v);\n+  CGFloat y = Double_val(y_v);\n+  CGFloat w = Double_val(w_v);\n+  CGFloat h = Double_val(h_v);\n+\n+  NSRect rect = NSMakeRect(x, y, w, h);\n+  [btn setFrame:rect];\n+\n+  CAMLreturn(Val_unit);\n+}\n+\n+CAMLprim value ml_NSButton_setCallback(value btn_v, value callback_v)\n+{\n+  CAMLparam2(btn_v, callback_v);\n+\n+  Button *btn = Button_val(btn_v);\n+  value callback = callback_v;\n+\n+  caml_register_global_root(&callback);\n+\n+  [btn onClick:^{\n+    NSLog(@\"sent\");\n+    caml_callback(callback, Val_unit);\n+  }];\n+\n+  CAMLreturn(Val_Button(btn));\n+}\n+\n+CAMLprim value ml_NSButton_setTitle(value btn_v, value str_v)","path":"renderer_cocoa/lib/Cocoa_stubs.c","position":452,"original_position":771,"commit_id":"d1e07bfe053d5345ce8314f80f44848ae74138ef","original_commit_id":"ac4b5d449ea2dcc09a3ab08f2dcf149d2a374cbd","user":{"login":"rauanmayemir","id":9691,"node_id":"MDQ6VXNlcjk2OTE=","avatar_url":"https://avatars0.githubusercontent.com/u/9691?v=4","gravatar_id":"","url":"https://api.github.com/users/rauanmayemir","html_url":"https://github.com/rauanmayemir","followers_url":"https://api.github.com/users/rauanmayemir/followers","following_url":"https://api.github.com/users/rauanmayemir/following{/other_user}","gists_url":"https://api.github.com/users/rauanmayemir/gists{/gist_id}","starred_url":"https://api.github.com/users/rauanmayemir/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rauanmayemir/subscriptions","organizations_url":"https://api.github.com/users/rauanmayemir/orgs","repos_url":"https://api.github.com/users/rauanmayemir/repos","events_url":"https://api.github.com/users/rauanmayemir/events{/privacy}","received_events_url":"https://api.github.com/users/rauanmayemir/received_events","type":"User","site_admin":false},"body":"Dropped as much as possible, but we need the title for demo purposes. 😁","created_at":"2018-09-15T10:45:19Z","updated_at":"2018-09-15T10:45:19Z","html_url":"https://github.com/briskml/brisk/pull/18#discussion_r217882127","pull_request_url":"https://api.github.com/repos/briskml/brisk/pulls/18","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/briskml/brisk/pulls/comments/217882127"},"html":{"href":"https://github.com/briskml/brisk/pull/18#discussion_r217882127"},"pull_request":{"href":"https://api.github.com/repos/briskml/brisk/pulls/18"}},"in_reply_to_id":216156020},"pull_request":{"url":"https://api.github.com/repos/briskml/brisk/pulls/18","id":204634616,"node_id":"MDExOlB1bGxSZXF1ZXN0MjA0NjM0NjE2","html_url":"https://github.com/briskml/brisk/pull/18","diff_url":"https://github.com/briskml/brisk/pull/18.diff","patch_url":"https://github.com/briskml/brisk/pull/18.patch","issue_url":"https://api.github.com/repos/briskml/brisk/issues/18","number":18,"state":"open","locked":false,"title":"[WIP] Cocoa renderer for macOS","user":{"login":"rauanmayemir","id":9691,"node_id":"MDQ6VXNlcjk2OTE=","avatar_url":"https://avatars0.githubusercontent.com/u/9691?v=4","gravatar_id":"","url":"https://api.github.com/users/rauanmayemir","html_url":"https://github.com/rauanmayemir","followers_url":"https://api.github.com/users/rauanmayemir/followers","following_url":"https://api.github.com/users/rauanmayemir/following{/other_user}","gists_url":"https://api.github.com/users/rauanmayemir/gists{/gist_id}","starred_url":"https://api.github.com/users/rauanmayemir/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rauanmayemir/subscriptions","organizations_url":"https://api.github.com/users/rauanmayemir/orgs","repos_url":"https://api.github.com/users/rauanmayemir/repos","events_url":"https://api.github.com/users/rauanmayemir/events{/privacy}","received_events_url":"https://api.github.com/users/rauanmayemir/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-07-29T10:01:07Z","updated_at":"2018-09-15T10:45:19Z","closed_at":null,"merged_at":null,"merge_commit_sha":"037d96a1b841f505e355cc8445235676d0635f2b","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/briskml/brisk/pulls/18/commits","review_comments_url":"https://api.github.com/repos/briskml/brisk/pulls/18/comments","review_comment_url":"https://api.github.com/repos/briskml/brisk/pulls/comments{/number}","comments_url":"https://api.github.com/repos/briskml/brisk/issues/18/comments","statuses_url":"https://api.github.com/repos/briskml/brisk/statuses/d1e07bfe053d5345ce8314f80f44848ae74138ef","head":{"label":"briskml:feature/cocoa-renderer","ref":"feature/cocoa-renderer","sha":"d1e07bfe053d5345ce8314f80f44848ae74138ef","user":{"login":"briskml","id":38274274,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM4Mjc0Mjc0","avatar_url":"https://avatars2.githubusercontent.com/u/38274274?v=4","gravatar_id":"","url":"https://api.github.com/users/briskml","html_url":"https://github.com/briskml","followers_url":"https://api.github.com/users/briskml/followers","following_url":"https://api.github.com/users/briskml/following{/other_user}","gists_url":"https://api.github.com/users/briskml/gists{/gist_id}","starred_url":"https://api.github.com/users/briskml/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/briskml/subscriptions","organizations_url":"https://api.github.com/users/briskml/orgs","repos_url":"https://api.github.com/users/briskml/repos","events_url":"https://api.github.com/users/briskml/events{/privacy}","received_events_url":"https://api.github.com/users/briskml/received_events","type":"Organization","site_admin":false},"repo":{"id":129271474,"node_id":"MDEwOlJlcG9zaXRvcnkxMjkyNzE0NzQ=","name":"brisk","full_name":"briskml/brisk","owner":{"login":"briskml","id":38274274,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM4Mjc0Mjc0","avatar_url":"https://avatars2.githubusercontent.com/u/38274274?v=4","gravatar_id":"","url":"https://api.github.com/users/briskml","html_url":"https://github.com/briskml","followers_url":"https://api.github.com/users/briskml/followers","following_url":"https://api.github.com/users/briskml/following{/other_user}","gists_url":"https://api.github.com/users/briskml/gists{/gist_id}","starred_url":"https://api.github.com/users/briskml/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/briskml/subscriptions","organizations_url":"https://api.github.com/users/briskml/orgs","repos_url":"https://api.github.com/users/briskml/repos","events_url":"https://api.github.com/users/briskml/events{/privacy}","received_events_url":"https://api.github.com/users/briskml/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/briskml/brisk","description":"Cross-platform set of tools for building native UIs with Reason/OCaml","fork":false,"url":"https://api.github.com/repos/briskml/brisk","forks_url":"https://api.github.com/repos/briskml/brisk/forks","keys_url":"https://api.github.com/repos/briskml/brisk/keys{/key_id}","collaborators_url":"https://api.github.com/repos/briskml/brisk/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/briskml/brisk/teams","hooks_url":"https://api.github.com/repos/briskml/brisk/hooks","issue_events_url":"https://api.github.com/repos/briskml/brisk/issues/events{/number}","events_url":"https://api.github.com/repos/briskml/brisk/events","assignees_url":"https://api.github.com/repos/briskml/brisk/assignees{/user}","branches_url":"https://api.github.com/repos/briskml/brisk/branches{/branch}","tags_url":"https://api.github.com/repos/briskml/brisk/tags","blobs_url":"https://api.github.com/repos/briskml/brisk/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/briskml/brisk/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/briskml/brisk/git/refs{/sha}","trees_url":"https://api.github.com/repos/briskml/brisk/git/trees{/sha}","statuses_url":"https://api.github.com/repos/briskml/brisk/statuses/{sha}","languages_url":"https://api.github.com/repos/briskml/brisk/languages","stargazers_url":"https://api.github.com/repos/briskml/brisk/stargazers","contributors_url":"https://api.github.com/repos/briskml/brisk/contributors","subscribers_url":"https://api.github.com/repos/briskml/brisk/subscribers","subscription_url":"https://api.github.com/repos/briskml/brisk/subscription","commits_url":"https://api.github.com/repos/briskml/brisk/commits{/sha}","git_commits_url":"https://api.github.com/repos/briskml/brisk/git/commits{/sha}","comments_url":"https://api.github.com/repos/briskml/brisk/comments{/number}","issue_comment_url":"https://api.github.com/repos/briskml/brisk/issues/comments{/number}","contents_url":"https://api.github.com/repos/briskml/brisk/contents/{+path}","compare_url":"https://api.github.com/repos/briskml/brisk/compare/{base}...{head}","merges_url":"https://api.github.com/repos/briskml/brisk/merges","archive_url":"https://api.github.com/repos/briskml/brisk/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/briskml/brisk/downloads","issues_url":"https://api.github.com/repos/briskml/brisk/issues{/number}","pulls_url":"https://api.github.com/repos/briskml/brisk/pulls{/number}","milestones_url":"https://api.github.com/repos/briskml/brisk/milestones{/number}","notifications_url":"https://api.github.com/repos/briskml/brisk/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/briskml/brisk/labels{/name}","releases_url":"https://api.github.com/repos/briskml/brisk/releases{/id}","deployments_url":"https://api.github.com/repos/briskml/brisk/deployments","created_at":"2018-04-12T15:20:12Z","updated_at":"2018-09-12T17:02:50Z","pushed_at":"2018-09-15T10:44:10Z","git_url":"git://github.com/briskml/brisk.git","ssh_url":"git@github.com:briskml/brisk.git","clone_url":"https://github.com/briskml/brisk.git","svn_url":"https://github.com/briskml/brisk","homepage":"","size":352,"stargazers_count":70,"watchers_count":70,"language":"OCaml","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1,"mirror_url":null,"archived":false,"open_issues_count":14,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":1,"open_issues":14,"watchers":70,"default_branch":"master"}},"base":{"label":"briskml:master","ref":"master","sha":"304c5aeb73ccf4ff946ae85f441f357d9aa3b815","user":{"login":"briskml","id":38274274,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM4Mjc0Mjc0","avatar_url":"https://avatars2.githubusercontent.com/u/38274274?v=4","gravatar_id":"","url":"https://api.github.com/users/briskml","html_url":"https://github.com/briskml","followers_url":"https://api.github.com/users/briskml/followers","following_url":"https://api.github.com/users/briskml/following{/other_user}","gists_url":"https://api.github.com/users/briskml/gists{/gist_id}","starred_url":"https://api.github.com/users/briskml/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/briskml/subscriptions","organizations_url":"https://api.github.com/users/briskml/orgs","repos_url":"https://api.github.com/users/briskml/repos","events_url":"https://api.github.com/users/briskml/events{/privacy}","received_events_url":"https://api.github.com/users/briskml/received_events","type":"Organization","site_admin":false},"repo":{"id":129271474,"node_id":"MDEwOlJlcG9zaXRvcnkxMjkyNzE0NzQ=","name":"brisk","full_name":"briskml/brisk","owner":{"login":"briskml","id":38274274,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM4Mjc0Mjc0","avatar_url":"https://avatars2.githubusercontent.com/u/38274274?v=4","gravatar_id":"","url":"https://api.github.com/users/briskml","html_url":"https://github.com/briskml","followers_url":"https://api.github.com/users/briskml/followers","following_url":"https://api.github.com/users/briskml/following{/other_user}","gists_url":"https://api.github.com/users/briskml/gists{/gist_id}","starred_url":"https://api.github.com/users/briskml/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/briskml/subscriptions","organizations_url":"https://api.github.com/users/briskml/orgs","repos_url":"https://api.github.com/users/briskml/repos","events_url":"https://api.github.com/users/briskml/events{/privacy}","received_events_url":"https://api.github.com/users/briskml/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/briskml/brisk","description":"Cross-platform set of tools for building native UIs with Reason/OCaml","fork":false,"url":"https://api.github.com/repos/briskml/brisk","forks_url":"https://api.github.com/repos/briskml/brisk/forks","keys_url":"https://api.github.com/repos/briskml/brisk/keys{/key_id}","collaborators_url":"https://api.github.com/repos/briskml/brisk/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/briskml/brisk/teams","hooks_url":"https://api.github.com/repos/briskml/brisk/hooks","issue_events_url":"https://api.github.com/repos/briskml/brisk/issues/events{/number}","events_url":"https://api.github.com/repos/briskml/brisk/events","assignees_url":"https://api.github.com/repos/briskml/brisk/assignees{/user}","branches_url":"https://api.github.com/repos/briskml/brisk/branches{/branch}","tags_url":"https://api.github.com/repos/briskml/brisk/tags","blobs_url":"https://api.github.com/repos/briskml/brisk/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/briskml/brisk/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/briskml/brisk/git/refs{/sha}","trees_url":"https://api.github.com/repos/briskml/brisk/git/trees{/sha}","statuses_url":"https://api.github.com/repos/briskml/brisk/statuses/{sha}","languages_url":"https://api.github.com/repos/briskml/brisk/languages","stargazers_url":"https://api.github.com/repos/briskml/brisk/stargazers","contributors_url":"https://api.github.com/repos/briskml/brisk/contributors","subscribers_url":"https://api.github.com/repos/briskml/brisk/subscribers","subscription_url":"https://api.github.com/repos/briskml/brisk/subscription","commits_url":"https://api.github.com/repos/briskml/brisk/commits{/sha}","git_commits_url":"https://api.github.com/repos/briskml/brisk/git/commits{/sha}","comments_url":"https://api.github.com/repos/briskml/brisk/comments{/number}","issue_comment_url":"https://api.github.com/repos/briskml/brisk/issues/comments{/number}","contents_url":"https://api.github.com/repos/briskml/brisk/contents/{+path}","compare_url":"https://api.github.com/repos/briskml/brisk/compare/{base}...{head}","merges_url":"https://api.github.com/repos/briskml/brisk/merges","archive_url":"https://api.github.com/repos/briskml/brisk/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/briskml/brisk/downloads","issues_url":"https://api.github.com/repos/briskml/brisk/issues{/number}","pulls_url":"https://api.github.com/repos/briskml/brisk/pulls{/number}","milestones_url":"https://api.github.com/repos/briskml/brisk/milestones{/number}","notifications_url":"https://api.github.com/repos/briskml/brisk/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/briskml/brisk/labels{/name}","releases_url":"https://api.github.com/repos/briskml/brisk/releases{/id}","deployments_url":"https://api.github.com/repos/briskml/brisk/deployments","created_at":"2018-04-12T15:20:12Z","updated_at":"2018-09-12T17:02:50Z","pushed_at":"2018-09-15T10:44:10Z","git_url":"git://github.com/briskml/brisk.git","ssh_url":"git@github.com:briskml/brisk.git","clone_url":"https://github.com/briskml/brisk.git","svn_url":"https://github.com/briskml/brisk","homepage":"","size":352,"stargazers_count":70,"watchers_count":70,"language":"OCaml","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1,"mirror_url":null,"archived":false,"open_issues_count":14,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":1,"open_issues":14,"watchers":70,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/briskml/brisk/pulls/18"},"html":{"href":"https://github.com/briskml/brisk/pull/18"},"issue":{"href":"https://api.github.com/repos/briskml/brisk/issues/18"},"comments":{"href":"https://api.github.com/repos/briskml/brisk/issues/18/comments"},"review_comments":{"href":"https://api.github.com/repos/briskml/brisk/pulls/18/comments"},"review_comment":{"href":"https://api.github.com/repos/briskml/brisk/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/briskml/brisk/pulls/18/commits"},"statuses":{"href":"https://api.github.com/repos/briskml/brisk/statuses/d1e07bfe053d5345ce8314f80f44848ae74138ef"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"rauanmayemir"}}