// ToNative converts protobuf Value to quad.Value.
489352
func (m *Value) ToNative() (qv quad.Value) {
	if m == nil {
		return nil
	}
	switch v := m.Value.(type) {
	case *Value_Raw:
		return quad.StringToValue(string(v.Raw))
	case *Value_Str:
		return quad.String(v.Str)
	case *Value_Iri:
		return quad.IRI(v.Iri)
	case *Value_Bnode:
		return quad.BNode(v.Bnode)
	case *Value_TypedStr:
		return quad.TypedString{
			Value: quad.String(v.TypedStr.Value),
			Type:  quad.IRI(v.TypedStr.Type),
		}
	case *Value_LangStr:
		return quad.LangString{
			Value: quad.String(v.LangStr.Value),
			Lang:  v.LangStr.Lang,
		}
	case *Value_Int:
		return quad.Int(v.Int)
	case *Value_Float:
		return quad.Float(v.Float)
	case *Value_Boolean:
		return quad.Bool(v.Boolean)
	case *Value_Time:
		var t time.Time
		if v.Time == nil {
			t = time.Unix(0, 0).UTC()
		} else {
			t = time.Unix(v.Time.Seconds, int64(v.Time.Nanos)).UTC()
		}
		return quad.Time(t)
	default:
		panic(fmt.Errorf("unsupported type: %T", m.Value))
	}
}
585749
func (o *Object) Literal() (*literal.Literal, error) {
	if o.l == nil {
		return nil, fmt.Errorf("triple.Literal does not box a literal in %s", o)
	}
	return o.l, nil
}
887707
func (m *StrictQuad) ToNative() (q quad.Quad) {
	if m == nil {
		return
	}
	if m.Subject != nil {
		q.Subject = m.Subject.ToNative()
	}
	if m.Predicate != nil {
		q.Predicate = m.Predicate.ToNative()
	}
	if m.Object != nil {
		q.Object = m.Object.ToNative()
	}
	if m.Label != nil {
		q.Label = m.Label.ToNative()
	}
	return
}
517592
func (d *Domain) IsActive() (bool, error) {
	var err C.virError
	result := C.virDomainIsActiveWrapper(d.ptr, &err)
	if result == -1 {
		return false, makeError(&err)
	}
	if result == 1 {
		return true, nil
	}
	return false, nil
}
639404
func (d *Context) PushBoolean(val bool) {
	var __val__ int
	if val {
		__val__ = 1
	}
	C.duk_push_boolean(d.duk_context, C.duk_bool_t(__val__))
}
914243
func (x duration) Unary(op syntax.Token) (starlark.Value, error) {
	switch op {
	case syntax.PLUS:
		return x, nil
	case syntax.MINUS:
		return duration{zero.Sub(x.Int)}, nil
	}
	return nil, nil
}
1194173
func (t *tree) parsePlural(tok item) ast.Node {
	const ctx = "plural"
	if !t.inmsg {
		t.unexpected(tok, "not in msg")
	}

	// plural and switch nodes have the same structure.
	// BUG: the location quoted the erorr messages will not be correct.
	var sw = t.parseSwitch(tok, itemPluralEnd).(*ast.SwitchNode)
	var defaultNode ast.ParentNode
	var cases []*ast.MsgPluralCaseNode
	for _, node := range sw.Cases {
		if len(node.Values) == 0 {
			defaultNode = node.Body.(ast.ParentNode)
		} else {
			var intNode, ok = node.Values[0].(*ast.IntNode)
			if !ok || len(node.Values) > 1 {
				t.errorf("plural case must be a single integer, got %v", node.Values)
			}
			cases = append(cases, &ast.MsgPluralCaseNode{node.Pos, int(intNode.Value), node.Body.(ast.ParentNode)})
		}
	}
	if defaultNode == nil {
		t.errorf("{default} case required")
	}
	return &ast.MsgPluralNode{sw.Pos, "", sw.Value, cases, defaultNode}
}
1130197
func (router *Router) StaticRelative(p string, relativeDir string) *Router {
	// TODO: is this needed?? ;)
	_, f, _, _ := runtime.Caller(1)
	return router.Static(p, path.Join(path.Dir(f), relativeDir))
}
418163
func ToNative(v Value) (interface{}, error) {
	var out interface{}
	var err error
	switch {
	case v.Type() == Null:
		// no-op
	case v.IsSigned():
		return ToInt64(v)
	case v.IsUnsigned():
		return ToUint64(v)
	case v.IsFloat():
		return ToFloat64(v)
	case v.IsQuoted() || v.Type() == Bit || v.Type() == Decimal:
		out = v.val
	case v.Type() == Expression:
		err = vterrors.Errorf(vtrpcpb.Code_INVALID_ARGUMENT, "%v cannot be converted to a go type", v)
	}
	return out, err
}
1336084
func getPrimitive(schema proto.Schema) (*proto.Primitive, error) {
	if schema == nil {
		return nil, nil
	}
	visitor := &primitiveSchemaVisitor{}
	schema.Accept(visitor)
	return visitor.Result, visitor.Err
}
45255
func ToLiteral(ce ConsumedElement) (*literal.Literal, error) {
	if ce.IsSymbol() {
		return nil, fmt.Errorf("semantic.ToLiteral cannot convert symbol %v to a literal", ce)
	}
	tkn := ce.Token()
	if tkn.Type != lexer.ItemLiteral {
		return nil, fmt.Errorf("semantic.ToLiteral cannot convert token type %s to a literal", tkn.Type)
	}
	return literal.DefaultBuilder().Parse(tkn.Text)
}
530543
func (l *Slog) ProtoLevel() *Slog {
	l = l.copy()
	l.Log.Priority = ProtoPrio
	return l
}
627288
func (e *EncodeSession) FrameDuration() time.Duration {
	return time.Duration(e.options.FrameDuration) * time.Millisecond
}
442626
func (h *Plus) toNormal() {
	if len(h.tmpSet) > 0 {
		h.mergeSparse()
	}

	h.denseList = make([]uint8, h.m)
	for iter := h.sparseList.Iter(); iter.HasNext(); {
		i, r := h.decodeHash(iter.Next())
		if h.denseList[i] < r {
			h.denseList[i] = r
		}
	}

	h.sparse = false
	h.tmpSet = nil
	h.sparseList = nil
}
564024
func (a ScmpCompareOp) toNative() C.int {
	switch a {
	case CompareNotEqual:
		return C.C_CMP_NE
	case CompareLess:
		return C.C_CMP_LT
	case CompareLessOrEqual:
		return C.C_CMP_LE
	case CompareEqual:
		return C.C_CMP_EQ
	case CompareGreaterEqual:
		return C.C_CMP_GE
	case CompareGreater:
		return C.C_CMP_GT
	case CompareMaskedEqual:
		return C.C_CMP_MASKED_EQ
	default:
		return 0x0
	}
}
1315274
func (d *Context) ToNull(index int) {
	C.duk_to_null(d.duk_context, C.duk_idx_t(index))
}
1066087
func (p *roundRobinResourcePool) NumActive() int32 {
	total := int32(0)

	p.rwMutex.RLock()
	defer p.rwMutex.RUnlock()

	for _, locPool := range p.pools {
		total += locPool.Pool.NumActive()
	}
	return total
}