当前位置: 首页>>代码示例>>Golang>>正文


Golang Object.Qualident方法代码示例

本文整理汇总了Golang中github.com/kpmy/ot/otm.Object.Qualident方法的典型用法代码示例。如果您正苦于以下问题:Golang Object.Qualident方法的具体用法?Golang Object.Qualident怎么用?Golang Object.Qualident使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/kpmy/ot/otm.Object的用法示例。


在下文中一共展示了Object.Qualident方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: prettyPrintObject

func prettyPrintObject(o otm.Object, log *testing.T) {
	parent := ""
	for x := o.Parent(); !fn.IsNil(x); x = x.Parent() {
		parent = fmt.Sprint(x.Qualident(), "<-", parent)
	}
	log.Log(parent, o.Qualident())
	if o.ChildrenCount() > 0 {
		log.Log(":")
		for _x := range o.Children() {
			switch x := _x.(type) {
			case otm.Object:
				prettyPrintObject(x, log)
			case otm.Link:
				log.Log("@", x.Object().Qualident())
			case string, float64, int64, rune, tri.Trit:
				log.Log(_x)
			case []uint8:
				s := zbase32.EncodeToString(x)
				log.Log("zbase32(", s, ")", x)
			default:
				halt.As(100, reflect.TypeOf(x))
			}
		}
		log.Log(";")
	}
}
开发者ID:kpmy,项目名称:ot,代码行数:26,代码来源:ot_test_stuff.go

示例2: ResolveContext

func ResolveContext(o otm.Object, resolver ResolverFunc, data map[string]interface{}) (err error) {
	assert.For(!fn.IsNil(o), 20)

	switch tpl := o.Qualident().Template; tpl {
	case Core.TemplateName:
		err = resolveContext(o.(*object), resolver, data)
	default:
		err = errors.New("nothing to resolve")
	}
	return
}
开发者ID:kpmy,项目名称:ot,代码行数:11,代码来源:imp.go

示例3: Resolve

func Resolve(o otm.Object) (err error) {
	assert.For(!fn.IsNil(o), 20)

	switch tpl := o.Qualident().Template; tpl {
	case Core.TemplateName:
		err = resolve(Core, o)
	default:
		err = errors.New("nothing to resolve")
	}
	return
}
开发者ID:kpmy,项目名称:ot,代码行数:11,代码来源:imp.go

示例4: object

func (f *fm) object(o otm.Object) {
	q := o.Qualident()
	if q.Template != "" {
		f.Ident(q.Template)
		f.Char('~')
	}
	f.Ident(q.Class)
	if q.Identifier != "" {
		f.Char('(')
		f.Ident(q.Identifier)
		f.Char(')')
	}
	if o.ChildrenCount() > 0 {
		f.Char(':')
		for _x := range o.Children() {
			f.Char(' ')
			switch x := _x.(type) {
			case otm.Object:
				f.object(x)
			case string:
				f.stringValue(x)
			case int64:
				i := strconv.Itoa(int(x))
				f.RawString(i)
			case float64:
				if math.IsInf(x, 1) {
					f.RawString("inf")
				} else if math.IsInf(x, -1) {
					f.RawString("-inf")
				} else {
					f_ := strconv.FormatFloat(x, 'f', 8, 64)
					f.RawString(f_)
				}
			case rune:
				r := strconv.FormatUint(uint64(x), 16)
				f.RawString("0" + r + "U")
			case tri.Trit:
				f.Trinary(x)
			case []uint8:
				f.RawString(zbase32.EncodeToString(x))
			default:
				halt.As(100, reflect.TypeOf(x))
			}
		}
		f.Char(';')
	} else {
		f.Char(' ')
	}
}
开发者ID:kpmy,项目名称:ot,代码行数:49,代码来源:g.go

示例5: renderHtml

func renderHtml(o otm.Object, log *testing.T) {
	buf := bytes.NewBufferString("<!DOCTYPE HTML>")
	e := xml.NewEncoder(buf)
	var obj func(otm.Object)
	obj = func(o otm.Object) {
		clazz := o.InstanceOf().Qualident()
		if clazz.Template == "html" {
			start := xml.StartElement{}
			start.Name.Local = clazz.Class
			if id := o.Qualident().Identifier; id != "" {
				attr := xml.Attr{}
				attr.Name.Local = "id"
				attr.Value = id
				start.Attr = append(start.Attr, attr)
			}
			e.EncodeToken(start)
			for _x := range o.Children() {
				switch x := _x.(type) {
				case otm.Object:
					obj(x)
				case string:
					e.EncodeToken(xml.CharData([]byte(x)))
				default:
					halt.As(100, reflect.TypeOf(x))
				}
			}
			e.EncodeToken(start.End())
		}
	}

	for x := range o.ChildrenObjects() {
		if x.InstanceOf().Qualident().Template == "html" && x.InstanceOf().Qualident().Class == "html" {
			obj(x)
		}
	}
	e.Flush()
	log.Log(buf.String())
}
开发者ID:kpmy,项目名称:ot,代码行数:38,代码来源:ot_test_stuff.go

示例6: resolve

func resolve(t *ForeignTemplate, o otm.Object) (err error) {
	assert.For(!fn.IsNil(o), 20)
	var processList []pfunc

	var upd func(t *ForeignTemplate, o otm.Object)
	upd = func(t *ForeignTemplate, o otm.Object) {
		if clazz, ok := t.Classes[o.Qualident().Class]; ok && (o.Qualident().Template == t.TemplateName || o.Qualident().Template == "") {
			inst := clazz.copyOf()
			o.InstanceOf(inst)
			if fn := inst.apply(o); fn != nil {
				processList = append(processList, fn)
			}
			//log.Println("class updated for", o.Qualident(), " set ", clazz.Qualident())
		}
		for x := range o.ChildrenObjects() {
			upd(t, x)
		}
	}

	upd(t, o)

	for tmp := processList; len(tmp) > 0; {
		var _tmp []pfunc
		for _, f := range tmp {
			var p pfunc
			if p, err = f(); err == nil && p != nil {
				_tmp = append(_tmp, p)
			} else if err != nil {
				_tmp = nil
				break
			}
		}
		tmp = _tmp
	}
	return
}
开发者ID:kpmy,项目名称:ot,代码行数:36,代码来源:imp.go

示例7: traverse

func (w *Walker) traverse(o otm.Object) {
	var (
		this    schema.Guide
		skip    *bool
		skipped = func() {
			s := true
			skip = &s
		}
		important = func() {
			s := false
			skip = &s
		}
	)

	switch o.Qualident().Class {
	//structure elements
	case "grammar":
		skipped()
		if start := o.FindByQualident(otm.Qualident{Template: "ng", Class: "start"}); start != nil {
			w.forEach(start[0], traverseWrap())
		}
	case "ref":
		skipped()
		panic(0)
		/*		if ref := w.root.FindByName(n.Name); ref != nil {
					if cached := w.cache[n.Name]; cached == nil {
						this = Construct(n.XMLName)
						{
							std.NameAttr(this, n.Name)
							//std.RefAttr(this, cached.root)
						}
						w.cache[n.Name] = &Cached{node: ref, root: this}
						w.GrowDown(this)
						w.forEach(ref, traverseWrap())
						w.Up()
					} else {
						w.Grow(cached.root)
					}
				} else {
					halt.As(100, "ref not found", n.Name)
				}
		*/
	//content elements
	case "element", "attribute", "data", "text", "value", "name", "param":
		fallthrough
	//constraint elements
	case "choice", "interleave", "optional", "zeroOrMore", "oneOrMore", "group", "list", "mixed", "except", "anyName", "nsName", "empty", "externalRef":
		important()
		this = Construct(o.Qualident())
		{
			std.NameAttr(this, NameOf(o))
			/*std.CharDataAttr(this, n.Data())
			std.TypeAttr(this, n.Type)
			std.NSAttr(this, n.NS)
			std.DataTypeAttr(this, n.DataType)
			std.CombineAttr(this, n.Combine)
			std.HrefAttr(this, n.Href)
			*/
		}
		w.GrowDown(this)
		w.forEach(o, traverseWrap())
		w.Up()
	//skipped elements
	case "description": //descriprion do nothing
	default:
		halt.As(100, o.Qualident())
	}
	if skip != nil {
		assert.For(*skip || this != nil, 60, "no result for ", o.Qualident())
	} else if this == nil {
		log.Println("unhandled", o.Qualident())
	}
}
开发者ID:kpmy,项目名称:ot,代码行数:73,代码来源:load.go


注:本文中的github.com/kpmy/ot/otm.Object.Qualident方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。