Exemplo n.º 1
0
func transformPermission(node1 *permissionNode, node2 *permissionNode) (tnode1, tnode2 *permissionNode, err os.Error) {
	p1 := *node1
	p2 := *node2
	p1.Permission, p2.Permission, err = ot.TransformPermission(node1.Permission, node2.Permission)
	tnode1 = &p1
	tnode2 = &p2
	return
}
Exemplo n.º 2
0
func transform(node1 otNode, node2 otNode) (tnode1, tnode2 otNode, err os.Error) {
	tnode1 = node1
	tnode2 = node2
	switch node1.(type) {
	case *mutationNode:
		switch node2.(type) {
		case *mutationNode:
			m1 := *(node1.(*mutationNode))
			m2 := *(node2.(*mutationNode))
			m1.mutation, m2.mutation, err = ot.Transform(node1.(*mutationNode).mutation, node2.(*mutationNode).mutation)
			tnode1 = &m1
			tnode2 = &m2
		case *permissionNode, *keepNode:
			// Do nothing by intention
		default:
			panic("Unknown node type")
		}
	case *permissionNode:
		switch node2.(type) {
		case *mutationNode, *keepNode:
			// Do nothing by intention
		case *permissionNode:
			p1 := *(node1.(*permissionNode))
			p2 := *(node2.(*permissionNode))
			p1.permission, p2.permission, err = ot.TransformPermission(node1.(*permissionNode).permission, node2.(*permissionNode).permission)
			tnode1 = &p1
			tnode2 = &p2
		default:
			panic("Unknown node type")
		}
	case *keepNode:
		// Do nothing by intention
	default:
		panic("Unknown node type")
	}
	return
}