mirror of
https://gitee.com/energye/energy.git
synced 2024-12-02 03:37:48 +08:00
92 lines
2.4 KiB
Go
92 lines
2.4 KiB
Go
//----------------------------------------
|
|
//
|
|
// 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"
|
|
"github.com/energye/energy/v2/common/imports"
|
|
"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)))
|
|
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)))
|
|
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)))
|
|
// 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))
|
|
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))
|
|
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)))
|
|
return result
|
|
}
|
|
|
|
func (m *ICefStreamWriter) Flush() int32 {
|
|
if !m.IsValid() {
|
|
return 0
|
|
}
|
|
r1, _, _ := imports.Proc(def.CefStreamWriter_Flush).Call(m.Instance())
|
|
return int32(r1)
|
|
}
|
|
|
|
func (m *ICefStreamWriter) MayBlock() bool {
|
|
if !m.IsValid() {
|
|
return false
|
|
}
|
|
r1, _, _ := imports.Proc(def.CefStreamWriter_MayBlock).Call(m.Instance())
|
|
return api.GoBool(r1)
|
|
}
|