// See: http://duktape.org/api.html#duk_require_type_mask
966284
func (d *Context) RequireTypeMask(index int, mask uint) {
	C._duk_require_type_mask(d.duk_context, C.duk_idx_t(index), C.duk_uint_t(mask))
}
700285
func (d *Context) RequireInt(index int) int {
	return int(C.duk_require_int(d.duk_context, C.duk_idx_t(index)))
}
415382
func (v *ValidationDefinition) Dup() *ValidationDefinition {
	return &ValidationDefinition{
		Values:    v.Values,
		Format:    v.Format,
		Pattern:   v.Pattern,
		Minimum:   v.Minimum,
		Maximum:   v.Maximum,
		MinLength: v.MinLength,
		MaxLength: v.MaxLength,
		Required:  v.Required,
	}
}
864154
func ipInMasks(ip net.IP, masks []net.IPNet) bool {
	for _, mask := range masks {
		if mask.Contains(ip) {
			return true
		}
	}
	return false
}
1088095
func generateMaskingKey() (maskingKey []byte, err error) {
	maskingKey = make([]byte, 4)
	if _, err = io.ReadFull(rand.Reader, maskingKey); err != nil {
		return
	}
	return
}
811433
func (d *Context) SetPrototype(index int) {
	C.duk_set_prototype(d.duk_context, C.duk_idx_t(index))
}
187897
func MaskToRegex(rawMask string) (*regexp.Regexp, error) {
	input := bytes.NewBufferString(rawMask)

	output := &bytes.Buffer{}
	output.WriteByte('^')

	for {
		c, err := input.ReadByte()
		if err != nil {
			break
		}

		if c == '\\' {
			c, err = input.ReadByte()
			if err != nil {
				output.WriteString(regexp.QuoteMeta("\\"))
				break
			}

			if c == '?' || c == '*' || c == '\\' {
				output.WriteString(regexp.QuoteMeta(string(c)))
			} else {
				output.WriteString(regexp.QuoteMeta("\\" + string(c)))
			}
		} else if trans, ok := maskTranslations[c]; ok {
			output.WriteString(trans)
		} else {
			output.WriteString(regexp.QuoteMeta(string(c)))
		}
	}

	output.WriteByte('$')

	return regexp.Compile(output.String())
}
329216
func (d *Context) RequireStackTop(top int) {
	C.duk_require_stack_top(d.duk_context, C.duk_idx_t(top))
}
1093144
func (cm AsStandard) MEditMask(resource string) *metadata.MEditMask {
	mem := metadata.MEditMask{}
	for _, cd := range cm.Elements[metadata.MIEditMask.Name] {
		if cd.Attr["Resource"] != resource {
			continue
		}
		metadata.FieldTransfer(cd.Attr).To(&mem)
		for _, entry := range cd.Entries() {
			tmp := metadata.EditMask{}
			entry.SetFields(&tmp)
			mem.EditMask = append(mem.EditMask, tmp)
		}
	}
	return &mem
}
5848
func InternalMaskableErrorf(format string, params ...interface{}) error {
	return maskInternal(fmt.Sprintf(format, params...))
}
1361147
func FieldMaskFromRequestBody(r io.Reader) (*field_mask.FieldMask, error) {
	fm := &field_mask.FieldMask{}
	var root interface{}
	if err := json.NewDecoder(r).Decode(&root); err != nil {
		if err == io.EOF {
			return fm, nil
		}
		return nil, err
	}

	queue := []fieldMaskPathItem{{node: root}}
	for len(queue) > 0 {
		// dequeue an item
		item := queue[0]
		queue = queue[1:]

		if m, ok := item.node.(map[string]interface{}); ok {
			// if the item is an object, then enqueue all of its children
			for k, v := range m {
				queue = append(queue, fieldMaskPathItem{path: append(item.path, generator.CamelCase(k)), node: v})
			}
		} else if len(item.path) > 0 {
			// otherwise, it's a leaf node so print its path
			fm.Paths = append(fm.Paths, strings.Join(item.path, "."))
		}
	}

	return fm, nil
}
1197264
func type_(thread *Thread, _ *Builtin, args Tuple, kwargs []Tuple) (Value, error) {
	if len(kwargs) > 0 {
		return nil, fmt.Errorf("type does not accept keyword arguments")
	}
	if len(args) != 1 {
		return nil, fmt.Errorf("type: got %d arguments, want exactly 1", len(args))
	}
	return String(args[0].Type()), nil
}
1160034
func validateUpdateMask(m *field_mask.FieldMask) error {
	switch {
	case m == nil:
		return status.Error(codes.InvalidArgument, "update mask is required")
	case len(m.Paths) == 0:
		return status.Error(codes.InvalidArgument, "at least one update mask path is required")
	}
	// Path names must be unique.
	// Keep records of ones we've already seen.
	paths := stringset.New(len(m.Paths))
	for _, path := range m.Paths {
		if !paths.Add(path) {
			return status.Errorf(codes.InvalidArgument, "duplicate update mask path %q", path)
		}
	}
	return nil
}
900251
func (c *Context) ColorMask(r, g, b, a bool) {
	c.Call("colorMask", r, g, b, a)
}
405422
func (d *Debugger) Types(filter string) ([]string, error) {
	d.processMutex.Lock()
	defer d.processMutex.Unlock()

	regex, err := regexp.Compile(filter)
	if err != nil {
		return nil, fmt.Errorf("invalid filter argument: %s", err.Error())
	}

	types, err := d.target.BinInfo().Types()
	if err != nil {
		return nil, err
	}

	r := make([]string, 0, len(types))
	for _, typ := range types {
		if regex.Match([]byte(typ)) {
			r = append(r, typ)
		}
	}

	return r, nil
}
888411
func MasksToPixelFormatEnum(bpp int, rmask, gmask, bmask, amask uint32) uint {
	return uint(C.SDL_MasksToPixelFormatEnum(C.int(bpp), C.Uint32(rmask), C.Uint32(gmask),
		C.Uint32(bmask), C.Uint32(amask)))
}
218503
func (d *Context) Dup(fromIndex int) {
	C.duk_dup(d.duk_context, C.duk_idx_t(fromIndex))
}