//export MojoMain
func MojoMain(handle C.MojoHandle) C.MojoResult {
	application.Run(&FortuneServerDelegate{
		fortuneFactory: FortuneFactory{
			fortune: NewFortuneImpl(),
		},
	}, system.MojoHandle(handle))
	return C.MOJO_RESULT_OK
}
Exemple #2
0
//export MojoMain
func MojoMain(handle C.MojoHandle) C.MojoResult {
	application.Run(&principalServiceDelegate{}, system.MojoHandle(handle))
	return C.MOJO_RESULT_OK
}
Exemple #3
0
//export MojoMain
func MojoMain(handle C.MojoHandle) C.MojoResult {
	application.Run(&HttpHandlerDelegate{}, system.MojoHandle(handle))
	return C.MOJO_RESULT_OK
}
//export MojoMain
func MojoMain(handle C.MojoHandle) C.MojoResult {
	application.Run(&V23ProxyTestServerDelegate{}, system.MojoHandle(handle))
	return C.MOJO_RESULT_OK
}
//export MojoMain
func MojoMain(handle C.MojoHandle) C.MojoResult {
	application.Run(&RemoteEchoClientDelegate{}, system.MojoHandle(handle))
	return C.MOJO_RESULT_OK
}
Exemple #6
0
//export MojoMain
func MojoMain(handle C.MojoHandle) C.MojoResult {
	application.Run(&delegate{stubs: map[*bindings.Stub]struct{}{}}, system.MojoHandle(handle))
	return C.MOJO_RESULT_OK
}
Exemple #7
0
// Parse parses a validation tests input string that has no comments.
// Panics if input has errors.
func (p *inputParser) Parse(s string) ([]byte, []system.UntypedHandle) {
	var bytes []byte
	var buf [8]byte
	// We need non-nil slice for comparing values with reflect.DeepEqual.
	handles := []system.UntypedHandle{}
	pointers := make(map[string]pointerPlaceholder)
	for _, item := range p.parseToDataItems(s) {
		switch item.Type {
		case "u1":
			var value uint8
			fmt.Sscan(item.Value, &value)
			bytes = append(bytes, byte(value))
		case "u2":
			var value uint16
			fmt.Sscan(item.Value, &value)
			binary.LittleEndian.PutUint16(buf[:2], value)
			bytes = append(bytes, buf[:2]...)
		case "u4":
			var value uint32
			fmt.Sscan(item.Value, &value)
			binary.LittleEndian.PutUint32(buf[:4], value)
			bytes = append(bytes, buf[:4]...)
		case "u8":
			var value uint64
			fmt.Sscan(item.Value, &value)
			binary.LittleEndian.PutUint64(buf[:8], value)
			bytes = append(bytes, buf[:8]...)
		case "s1":
			var value int8
			fmt.Sscan(item.Value, &value)
			bytes = append(bytes, byte(value))
		case "s2":
			var value int16
			fmt.Sscan(item.Value, &value)
			binary.LittleEndian.PutUint16(buf[:2], uint16(value))
			bytes = append(bytes, buf[:2]...)
		case "s4":
			var value int32
			fmt.Sscan(item.Value, &value)
			binary.LittleEndian.PutUint32(buf[:4], uint32(value))
			bytes = append(bytes, buf[:4]...)
		case "s8":
			var value int64
			fmt.Sscan(item.Value, &value)
			binary.LittleEndian.PutUint64(buf[:8], uint64(value))
			bytes = append(bytes, buf[:8]...)
		case "b":
			var value byte
			for i := 0; i < 8; i++ {
				value <<= 1
				if item.Value[i] == '1' {
					value++
				}
			}
			bytes = append(bytes, value)
		case "f":
			var value float32
			fmt.Sscan(item.Value, &value)
			binary.LittleEndian.PutUint32(buf[:4], math.Float32bits(value))
			bytes = append(bytes, buf[:4]...)
		case "d":
			var value float64
			fmt.Sscan(item.Value, &value)
			binary.LittleEndian.PutUint64(buf[:8], math.Float64bits(value))
			bytes = append(bytes, buf[:8]...)
		case "dist4":
			pointers[item.Value] = pointerPlaceholder{len(bytes), 4}
			bytes = append(bytes, buf[:4]...)
		case "dist8":
			pointers[item.Value] = pointerPlaceholder{len(bytes), 8}
			bytes = append(bytes, buf[:8]...)
		case "anchr":
			placeholder := pointers[item.Value]
			dist := len(bytes) - placeholder.Position
			switch placeholder.Size {
			case 4:
				binary.LittleEndian.PutUint32(bytes[placeholder.Position:], uint32(dist))
			case 8:
				binary.LittleEndian.PutUint64(bytes[placeholder.Position:], uint64(dist))
			}
			delete(pointers, item.Value)
		case "handles":
			var value int
			fmt.Sscan(item.Value, &value)
			handles = make([]system.UntypedHandle, value)
			for i, _ := range handles {
				handles[i] = &mockHandle{handle: system.MojoHandle(i + 1)}
			}
		default:
			panic(fmt.Sprintf("unsupported item type: %v", item.Type))
		}
	}
	if len(pointers) != 0 {
		panic(fmt.Sprintf("unmatched pointers: %v", pointers))
	}
	return bytes, handles
}