whale

package
v0.0.0-...-6f0ee80 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 25, 2016 License: MPL-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TOP = iota
	BOTTOM
	BEFORE
	AFTER
)
View Source
const OutputBufferSize = 500 * 1024 //500KB
View Source
const TimeoutError = "EngineTimeout"

Variables

View Source
var Positions = map[string]Position{
	"top":    TOP,
	"bottom": BOTTOM,
	"before": BEFORE,
	"after":  AFTER,
	"above":  BEFORE,
	"below":  AFTER,
}
View Source
var TritiumLogRewritersAsImports = false

Functions

func CleanRegexpObject

func CleanRegexpObject(object cache.CacheObject) error

func CleanXpathExpObject

func CleanXpathExpObject(object cache.CacheObject) error

func GenerateHostMapKey

func GenerateHostMapKey(key, secure string) (newKey string, append_proto, append_slashes bool)

func GetCharsetFromContentType

func GetCharsetFromContentType(ct string) string

func IsDomainCovered

func IsDomainCovered(domain1, domain2 string) bool

true if domain1 is less restrictive than domain2

func LogEngineError

func LogEngineError(ctx *EngineContext, errmsg string)

func LookupBuiltIn

func LookupBuiltIn(name string) builtInFunc

func MoveFunc

func MoveFunc(what, where hx.Node, position Position)

func NodeToJson

func NodeToJson(node hx.Node) (retVal interface{})

func NodeToJsonArray

func NodeToJsonArray(node hx.Node, json []interface{}) []interface{}

func NodeToJsonHash

func NodeToJsonHash(node hx.Node, json map[string]interface{}) map[string]interface{}

func ReformatHostMapValue

func ReformatHostMapValue(value string, append_proto, append_slashes bool) (newValue string)

func UpdateEnv

func UpdateEnv(env map[string]string, export [][]string)

func WrapJsonError

func WrapJsonError(err interface{}) map[string]string

Types

type EngineContext

type EngineContext struct {
	Functions                []*Function
	Types                    []string
	Exports                  [][]string
	Logs                     []string
	ImportedFiles            []string
	Env                      map[string]string
	MatchStack               []string
	MatchShouldContinueStack []bool
	Yields                   []*YieldBlock
	*Whale
	protoface.Transform
	Rrules []protoface.RewriteRule

	InnerReplacer     *rubex.Regexp
	HeaderContentType *rubex.Regexp

	// Debug info
	Filename    string
	HadError    bool
	Deadline    time.Time
	Mobjects    []MemoryObject
	MessagePath string
	Customer    string
	Project     string
	InDebug     bool
	CurrentDoc  interface{}
	Warnings    int
	Prod        bool
	HtmlParsed  bool
	Constants   map[string]string

	ActiveLayers       map[string]bool
	ActiveLayersString string
	HtmlTransformer    hx.HtmlTransformer
}

func NewEngineCtx

func NewEngineCtx(eng *Whale, vars, constants map[string]string, transform protoface.Transform, rrules []protoface.RewriteRule, deadline time.Time, messagePath, customer, project string, activeLayers []string, inDebug bool) (ctx *EngineContext)

func (*EngineContext) AddExport

func (ctx *EngineContext) AddExport(exports []string)

func (*EngineContext) AddLog

func (ctx *EngineContext) AddLog(log string) int

func (*EngineContext) AddMemoryObject

func (ctx *EngineContext) AddMemoryObject(o MemoryObject)

func (*EngineContext) FileAndLine

func (ctx *EngineContext) FileAndLine(ins protoface.Instruction) string

func (*EngineContext) Free

func (ctx *EngineContext) Free()

func (*EngineContext) GetEnv

func (ctx *EngineContext) GetEnv(key string) (val string)

func (*EngineContext) GetHeaderContentTypeRegex

func (ctx *EngineContext) GetHeaderContentTypeRegex() (r *rubex.Regexp)

func (*EngineContext) GetInnerReplacer

func (ctx *EngineContext) GetInnerReplacer() (r *rubex.Regexp)

func (*EngineContext) GetOutputBuffer

func (ctx *EngineContext) GetOutputBuffer() (b []byte)

func (*EngineContext) GetRegexp

func (ctx *EngineContext) GetRegexp(pattern, options string) (r *rubex.Regexp)

func (*EngineContext) GetVar

func (ctx *EngineContext) GetVar(key string) (val interface{})

func (*EngineContext) GetXpathExpr

func (ctx *EngineContext) GetXpathExpr(p string) (e hx.Selector)

func (*EngineContext) HasYieldBlock

func (ctx *EngineContext) HasYieldBlock() bool

func (*EngineContext) MatchTarget

func (ctx *EngineContext) MatchTarget() string

func (*EngineContext) PopMatchStack

func (ctx *EngineContext) PopMatchStack() (match string)

func (*EngineContext) PopShouldContinueStack

func (ctx *EngineContext) PopShouldContinueStack() (cont bool)

func (*EngineContext) PopYieldBlock

func (ctx *EngineContext) PopYieldBlock() (b *YieldBlock)

func (*EngineContext) PushMatchStack

func (ctx *EngineContext) PushMatchStack(match string)

func (*EngineContext) PushShouldContinueStack

func (ctx *EngineContext) PushShouldContinueStack(cont bool)

func (*EngineContext) PushYieldBlock

func (ctx *EngineContext) PushYieldBlock(b *YieldBlock)

func (*EngineContext) RunInstruction

func (ctx *EngineContext) RunInstruction(scope *Scope, ins protoface.Instruction) (returnValue interface{})

func (*EngineContext) SetEnv

func (ctx *EngineContext) SetEnv(key, val string)

func (*EngineContext) SetShouldContinue

func (ctx *EngineContext) SetShouldContinue(cont bool)

func (*EngineContext) SetVar

func (ctx *EngineContext) SetVar(key string, val interface{})

func (*EngineContext) ShouldContinue

func (ctx *EngineContext) ShouldContinue() (result bool)

func (*EngineContext) TopYieldBlock

func (ctx *EngineContext) TopYieldBlock() (b *YieldBlock)

func (*EngineContext) UpdateLog

func (ctx *EngineContext) UpdateLog(index int, log string)

func (*EngineContext) UsePackage

func (ctx *EngineContext) UsePackage(pkg protoface.Package)

func (*EngineContext) Vars

func (ctx *EngineContext) Vars() map[string]interface{}

type Function

type Function struct {
	Name string
	protoface.Function
}

type MemoryObject

type MemoryObject interface {
	Free()
}

type Position

type Position int

type RegexpObject

type RegexpObject struct {
	*rubex.Regexp
}

func (*RegexpObject) Size

func (o *RegexpObject) Size() int

type Scope

type Scope struct {
	Value interface{}
	Index int
}

type Whale

type Whale struct {
	Debugger    steno.Debugger
	RegexpCache cache.Cache
	XPathCache  map[string]hx.Selector
}

func NewEngine

func NewEngine(debugger steno.Debugger) *Whale

func (*Whale) Free

func (eng *Whale) Free()

func (*Whale) GetCacheStats

func (eng *Whale) GetCacheStats() (int, int)

func (*Whale) Run

func (eng *Whale) Run(transform protoface.Transform, rrules []protoface.RewriteRule, input interface{}, vars, constants map[string]string, deadline time.Time, customer, project, messagePath string, activeLayers []string, inDebug bool) (exhaust *tritium.Exhaust)

type XpathExpObject

type XpathExpObject struct {
	hx.Selector
}

func (*XpathExpObject) Size

func (o *XpathExpObject) Size() int

type YieldBlock

type YieldBlock struct {
	Ins      protoface.Instruction
	Vars     map[string]interface{}
	Filename string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL