func goSciterHostCallback(ph unsafe.Pointer, callbackParam unsafe.Pointer) int {
	phdr := (*SciterCallbackNotification)(ph)
	handler := globalCallbackHandlers[int(uintptr(callbackParam))]
	switch phdr.Code {
	case SC_ENGINE_DESTROYED:
		if handler.OnEngineDestroyed != nil {
			return handler.OnEngineDestroyed()
		}
	case SC_LOAD_DATA:
		if handler.OnLoadData != nil {
			return handler.OnLoadData((*ScnLoadData)(unsafe.Pointer(phdr)))
		}
	case SC_DATA_LOADED:
		if handler.OnDataLoaded != nil {
			return handler.OnDataLoaded((*ScnDataLoaded)(unsafe.Pointer(phdr)))
		}
	case SC_ATTACH_BEHAVIOR:
		params := (*ScnAttachBehavior)(unsafe.Pointer(phdr))
		key := params.BehaviorName()
		if behavior, exists := handler.Behaviors[key]; exists {
			if refCount, exists := behaviors[behavior]; exists {
				behaviors[behavior] = refCount + 1
			} else {
				behaviors[behavior] = 1
			}
			el := WrapElement(params.Element())
			el.attachBehavior(behavior)
		} else {
			log.Printf("No such behavior <%s> found", key)
		}
	}
	return 0
}
typedef UINT SC_CALLBACK SciterHostCallback( LPSCITER_CALLBACK_NOTIFICATION pns, LPVOID callbackParam );
export goSciterHostCallback
package sciter
import "C"
import (
	"fmt"
	"log"
	"runtime"
	"strings"
	"unsafe"
)
type Sciter struct {
	hwnd C.HWINDOW
	callbacks map[*CallbackHandler]struct{}
	*eventMapper
	har C.HSARCHIVE
}
var (
	BAD_HWINDOW C.HWINDOW = nil
)
func Wrap(hwnd C.HWINDOW) *Sciter {
	s := &Sciter{
		hwnd:      hwnd,
		callbacks: make(map[*CallbackHandler]struct{}),
	}
	return s
}
func ClassName() string {
	cname := (*uint16)(unsafe.Pointer(C.SciterClassName()))
	return Utf16ToString(cname)
}
func Version(major bool) uint {
	var v C.UINT
	if major {
		v = C.SciterVersion(C.BOOL(1))
	} else {
		v = C.SciterVersion(C.BOOL(0))
	}
	return uint(v)
}
func VersionAsString() string {
	major := Version(true)
	minor := Version(false)
	return fmt.Sprintf("0x%x %x", major, minor)
}
func (s *Sciter) GetHwnd() C.HWINDOW {
	return s.hwnd
}
func SetDLL(dir string) {
	C.SCITER_DLL_PATH = C.CString(dir)
}
func (s *Sciter) DataReady(uri string, data []byte) bool {
	var pData C.LPCBYTE
	if len(data) > 0 {
		pData = (C.LPCBYTE)(unsafe.Pointer(&data[0]))
	}
	ret := C.SciterDataReady(s.hwnd, StringToWcharPtr(uri), pData, C.UINT(len(data)))
	if ret == 0 {
		return false
	}
	loadedUri[uri] = data
	return true
}
var (
	loadedUri = map[string][]byte{}
)
func (s *Sciter) DataReadyAsync(uri string, data []byte, requestId unsafe.Pointer) bool {
	var pData C.LPCBYTE
	if len(data) > 0 {
		pData = (C.LPCBYTE)(unsafe.Pointer(&data[0]))
	}
	curi := StringToWcharPtr(uri)
	cdataLength := C.UINT(len(data))
	crequestId := C.LPVOID(requestId)
	ret := C.SciterDataReadyAsync(s.hwnd, curi, pData, cdataLength, crequestId)
	if ret == 0 {
		return false
	}
	return true
}
func (s *Sciter) LoadFile(filename string) error {
	ret := C.SciterLoadFile(s.hwnd, StringToWcharPtr(filename))
	if ret == 0 {
		return fmt.Errorf("LoadFile with: %s failed", filename)
	}
	return nil
}
func (s *Sciter) LoadHtml(html, baseUrl string) error {
	chtml := (C.LPCBYTE)(unsafe.Pointer(StringToBytePtr(html)))
	csize := C.UINT(len(html))
	cbaseUrl := StringToWcharPtr(baseUrl)
	ret := C.SciterLoadHtml(s.hwnd, chtml, csize, cbaseUrl)
	if ret == 0 {
		return fmt.Errorf("LoadHtml with: %s failed", string(html))
	}
	return nil
}