mirror of
https://github.com/superseriousbusiness/gotosocial
synced 2025-06-05 21:59:39 +02:00
[experiment] add alternative wasm sqlite3 implementation available via build-tag (#2863)
This allows for building GoToSocial with [SQLite transpiled to WASM](https://github.com/ncruces/go-sqlite3) and accessed through [Wazero](https://wazero.io/).
This commit is contained in:
51
vendor/github.com/tetratelabs/wazero/internal/wasm/counts.go
generated
vendored
Normal file
51
vendor/github.com/tetratelabs/wazero/internal/wasm/counts.go
generated
vendored
Normal file
@ -0,0 +1,51 @@
|
||||
package wasm
|
||||
|
||||
import "fmt"
|
||||
|
||||
// SectionElementCount returns the count of elements in a given section ID
|
||||
//
|
||||
// For example...
|
||||
// * SectionIDType returns the count of FunctionType
|
||||
// * SectionIDCustom returns the count of CustomSections plus one if NameSection is present
|
||||
// * SectionIDHostFunction returns the count of HostFunctionSection
|
||||
// * SectionIDExport returns the count of unique export names
|
||||
func (m *Module) SectionElementCount(sectionID SectionID) uint32 { // element as in vector elements!
|
||||
switch sectionID {
|
||||
case SectionIDCustom:
|
||||
numCustomSections := uint32(len(m.CustomSections))
|
||||
if m.NameSection != nil {
|
||||
numCustomSections++
|
||||
}
|
||||
return numCustomSections
|
||||
case SectionIDType:
|
||||
return uint32(len(m.TypeSection))
|
||||
case SectionIDImport:
|
||||
return uint32(len(m.ImportSection))
|
||||
case SectionIDFunction:
|
||||
return uint32(len(m.FunctionSection))
|
||||
case SectionIDTable:
|
||||
return uint32(len(m.TableSection))
|
||||
case SectionIDMemory:
|
||||
if m.MemorySection != nil {
|
||||
return 1
|
||||
}
|
||||
return 0
|
||||
case SectionIDGlobal:
|
||||
return uint32(len(m.GlobalSection))
|
||||
case SectionIDExport:
|
||||
return uint32(len(m.ExportSection))
|
||||
case SectionIDStart:
|
||||
if m.StartSection != nil {
|
||||
return 1
|
||||
}
|
||||
return 0
|
||||
case SectionIDElement:
|
||||
return uint32(len(m.ElementSection))
|
||||
case SectionIDCode:
|
||||
return uint32(len(m.CodeSection))
|
||||
case SectionIDData:
|
||||
return uint32(len(m.DataSection))
|
||||
default:
|
||||
panic(fmt.Errorf("BUG: unknown section: %d", sectionID))
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user