github.com/moontrade/nogc@v0.1.7/collections/robinhood/robinhood.go (about)

     1  //go:build !tinygo
     2  // +build !tinygo
     3  
     4  package robinhood
     5  
     6  /*
     7  
     8  #cgo CXXFLAGS: -std=c++14
     9  #cgo darwin,amd64 LDFLAGS: -Wl,-rpath,${SRCDIR}/lib/darwin_amd64 -L${SRCDIR}/lib/darwin_amd64
    10  #cgo darwin,amd64 LDFLAGS: -lrobinhood
    11  #include <stdlib.h>
    12  #include "library.h"
    13  
    14  void do_robinhood_hello(size_t arg0, size_t arg1) {
    15  	robinhood_hello(0, 0);
    16  }
    17  */
    18  import "C"
    19  import (
    20  	"github.com/moontrade/nogc/unsafecgo"
    21  	"unsafe"
    22  )
    23  
    24  type Tree uintptr
    25  
    26  type rhNewT struct {
    27  	ptr  uintptr
    28  	code uintptr
    29  }
    30  
    31  func New() *Tree {
    32  	args := rhNewT{}
    33  	ptr := uintptr(unsafe.Pointer(&args))
    34  	unsafecgo.NonBlocking((*byte)(C.do_robinhood_hello), ptr, 0)
    35  	return (*Tree)(unsafe.Pointer(args.ptr))
    36  }