energy/cef/types-stream-writer.go

92 lines
2.4 KiB
Go
Raw Normal View History

2023-05-31 17:41:14 +08:00
//----------------------------------------
//
// Copyright © yanghy. All Rights Reserved.
//
// Licensed under Apache License Version 2.0, January 2004
//
// https://www.apache.org/licenses/LICENSE-2.0
//
//----------------------------------------
package cef
import (
"github.com/energye/energy/v2/cef/internal/def"
2023-05-31 18:00:34 +08:00
"github.com/energye/energy/v2/common/imports"
2023-05-31 17:41:14 +08:00
"github.com/energye/golcl/lcl/api"
"unsafe"
)
// StreamWriterRef -> ICefStreamWriter
var StreamWriterRef streamWriter
type streamWriter uintptr
func (*streamWriter) UnWrap(data *ICefStreamWriter) *ICefStreamWriter {
var result uintptr
imports.Proc(def.CefStreamWriterRef_UnWrap).Call(data.Instance(), uintptr(unsafe.Pointer(&result)))
2023-05-31 17:41:14 +08:00
if result != 0 {
data.instance = unsafe.Pointer(result)
return data
}
return nil
}
func (*streamWriter) NewForFile(filename string) *ICefStreamWriter {
var result uintptr
imports.Proc(def.CefStreamWriterRef_CreateForFile).Call(api.PascalStr(filename), uintptr(unsafe.Pointer(&result)))
2023-05-31 17:41:14 +08:00
if result != 0 {
return &ICefStreamWriter{NewBaseRefCounted(result)}
}
return nil
}
//func (*streamWriter) NewForHandler(filename string) *ICefStreamWriter {
// var result uintptr
// imports.Proc(CefStreamWriterRef_CreateForHandler).Call(api.PascalStr(filename), uintptr(unsafe.Pointer(&result)))
2023-05-31 17:41:14 +08:00
// if result != 0 {
// return &ICefStreamWriter{NewBaseRefCounted(result)}
// }
// return nil
//}
func (m *ICefStreamWriter) Write(data []byte, size, n uint32) uint32 {
if !m.IsValid() {
return 0
}
r1, _, _ := imports.Proc(def.CefStreamWriter_Write).Call(m.Instance(), uintptr(unsafe.Pointer(&data[0])), uintptr(size), uintptr(n))
2023-05-31 17:41:14 +08:00
return uint32(r1)
}
func (m *ICefStreamWriter) Seek(offset int64, whence int32) int32 {
if !m.IsValid() {
return 0
}
r1, _, _ := imports.Proc(def.CefStreamWriter_Seek).Call(m.Instance(), uintptr(offset), uintptr(whence))
2023-05-31 17:41:14 +08:00
return int32(r1)
}
func (m *ICefStreamWriter) Tell() (result int64) {
if !m.IsValid() {
return 0
}
imports.Proc(def.CefStreamWriter_Tell).Call(m.Instance(), uintptr(unsafe.Pointer(&result)))
2023-05-31 17:41:14 +08:00
return result
}
func (m *ICefStreamWriter) Flush() int32 {
if !m.IsValid() {
return 0
}
r1, _, _ := imports.Proc(def.CefStreamWriter_Flush).Call(m.Instance())
2023-05-31 17:41:14 +08:00
return int32(r1)
}
func (m *ICefStreamWriter) MayBlock() bool {
if !m.IsValid() {
return false
}
r1, _, _ := imports.Proc(def.CefStreamWriter_MayBlock).Call(m.Instance())
2023-05-31 17:41:14 +08:00
return api.GoBool(r1)
}