示例#1
0
文件: main.go 项目: vanadium/croupier
func onStart(glctx gl.Context, u *uistate.UIState) {
	flag.Set("v23.credentials", "/sdcard/credentials")
	vlog.Log.Configure(vlog.OverridePriorConfiguration(true), vlog.LogToStderr(true))
	vlog.Log.Configure(vlog.OverridePriorConfiguration(true), vlog.Level(0))
	ctx, shutdown := v23.Init()
	u.Shutdown = shutdown
	u.Ctx = ctx
	u.Service = syncbase.NewService(util.MountPoint + "/croupier/" + util.SBName)
	namespace := v23.GetNamespace(u.Ctx)
	allAccess := access.AccessList{In: []security.BlessingPattern{"..."}}
	permissions := access.Permissions{
		"Admin":   allAccess,
		"Write":   allAccess,
		"Read":    allAccess,
		"Resolve": allAccess,
		"Debug":   allAccess,
	}
	namespace.SetPermissions(u.Ctx, util.MountPoint, permissions, "")
	namespace.SetPermissions(u.Ctx, util.MountPoint+"/croupier", permissions, "")
	u.Service.SetPermissions(u.Ctx, permissions, "")
	u.Images = glutil.NewImages(glctx)
	fps = debug.NewFPS(u.Images)
	u.Eng = glsprite.Engine(u.Images)
	u.Texs = texture.LoadTextures(u.Eng)
	u.CurTable = table.InitializeGame(u.NumPlayers, u.Texs)
	sound.InitPlayers(u)
	sync.CreateTables(u)
	// Create watch stream to update game state based on Syncbase updates
	go sync.UpdateSettings(u)
}
示例#2
0
//export swift_io_v_v23_V_nativeInitLogging
func swift_io_v_v23_V_nativeInitLogging(logDir *C.char, logToStderr bool, logLevel int, moduleSpec *C.char, errOut *C.SwiftVError) {
	dir, toStderr, level, vmodule, err := loggingOpts(C.GoString(logDir), logToStderr, logLevel, C.GoString(moduleSpec))
	if err != nil {
		sutil.ThrowSwiftError(nil, err, unsafe.Pointer(errOut))
		return
	}
	vlog.Log.Configure(vlog.OverridePriorConfiguration(true), dir, toStderr, level, vmodule)
}
示例#3
0
//export Java_io_v_android_v23_V_nativeInitGlobalAndroid
func Java_io_v_android_v23_V_nativeInitGlobalAndroid(jenv *C.JNIEnv, _ C.jclass, jOptions C.jobject) {
	env := jutil.Env(uintptr(unsafe.Pointer(jenv)))
	jOpts := jutil.Object(uintptr(unsafe.Pointer(jOptions)))

	// Don't allow broken stderr/out to kill our program due to
	// sigpipe.  Note that we just ignore all these signals.
	ch := make(chan os.Signal)
	signal.Notify(ch, syscall.SIGPIPE)

	if err := Init(env); err != nil {
		jutil.JThrowV(env, err)
		return
	}

	// Setup logging.
	_, _, level, vmodule, err := loggingOpts(env, jOpts)
	if err != nil {
		jutil.JThrowV(env, err)
		return
	}
	// Disable any logging to STDERR.
	// This assumes that vlog.Log is the underlying logging system for.
	vlog.Log.Configure(vlog.OverridePriorConfiguration(true), vlog.LogToStderr(false), vlog.AlsoLogToStderr(false), level, vmodule)

	// Setup discovery plugins.
	if err := jdplugins.Init(env); err != nil {
		jutil.JThrowV(env, err)
		return
	}

	// Setup namespace.
	android.SetNamespaceFactory(func(ctx *context.T, ns namespace.T, _ ...string) (namespace.T, error) {
		env, freeFunc := jutil.GetEnv()
		defer freeFunc()
		jContext, err := jcontext.JavaContext(env, ctx, nil)
		if err != nil {
			return nil, err
		}
		contextSign := jutil.ClassSign("io.v.v23.context.VContext")
		wakeupMountRoot, err := jutil.CallStaticStringMethod(env, jVClass, "getWakeupMountRoot", []jutil.Sign{contextSign}, jContext)
		if err != nil {
			return nil, err
		}
		if wakeupMountRoot == "" {
			return ns, nil
		}
		if !naming.Rooted(wakeupMountRoot) {
			return nil, fmt.Errorf("wakeup mount root %s must be ... rooted.", wakeupMountRoot)
		}
		return &wakeupNamespace{
			wakeupMountRoot: wakeupMountRoot,
			ns:              ns,
		}, nil
	})
}
示例#4
0
//export Java_io_v_v23_V_nativeInitGlobalJava
func Java_io_v_v23_V_nativeInitGlobalJava(jenv *C.JNIEnv, jVClass C.jclass, jOptions C.jobject) {
	env := jutil.Env(uintptr(unsafe.Pointer(jenv)))
	jOpts := jutil.Object(uintptr(unsafe.Pointer(jOptions)))

	// Setup logging.
	dir, toStderr, level, vmodule, err := loggingOpts(env, jOpts)
	if err != nil {
		jutil.JThrowV(env, err)
		return
	}
	vlog.Log.Configure(vlog.OverridePriorConfiguration(true), dir, toStderr, level, vmodule)
}
示例#5
0
//export swift_io_v_v23_V_nativeInitGlobal
func swift_io_v_v23_V_nativeInitGlobal(credentialsDir *C.char, errOut *C.SwiftVError) {
	// Send all vlog logs to stderr during the init so that we don't crash on android trying
	// to create a log file.  These settings will be overwritten in nativeInitLogging below.
	vlog.Log.Configure(vlog.OverridePriorConfiguration(true), vlog.LogToStderr(true))

	if credentialsDir != nil {
		dir := C.GoString(credentialsDir)
		os.Setenv(ref.EnvCredentials, dir)
	}
	if err := sv23.Init(); err != nil {
		sutil.ThrowSwiftError(nil, err, unsafe.Pointer(errOut))
		return
	}
	if err := sgoogle.Init(); err != nil {
		sutil.ThrowSwiftError(nil, err, unsafe.Pointer(errOut))
		return
	}
}
示例#6
0
文件: jni.go 项目: vanadium/go.jni
//export Java_io_v_v23_V_nativeInitGlobalShared
func Java_io_v_v23_V_nativeInitGlobalShared(jenv *C.JNIEnv, jVClass C.jclass) {
	env := jutil.Env(uintptr(unsafe.Pointer(jenv)))
	// Ignore all args except for the first one.
	if len(os.Args) > 1 {
		os.Args = os.Args[:1]
	}
	// Send all vlog logs to stderr during the init so that we don't crash on android trying
	// to create a log file.  These settings will be overwritten in
	// nativeInitJava/nativeInitAndroid.
	vlog.Log.Configure(vlog.OverridePriorConfiguration(true), vlog.LogToStderr(true))

	if err := jutil.Init(env); err != nil {
		jutil.JThrowV(env, err)
		return
	}
	if err := jv23.Init(env); err != nil {
		jutil.JThrowV(env, err)
		return
	}
	if err := jgoogle.Init(env); err != nil {
		jutil.JThrowV(env, err)
		return
	}
}