diff --git a/app/darwin_desktop.go b/app/darwin_desktop.go index 6b9ec94..3377175 100644 --- a/app/darwin_desktop.go +++ b/app/darwin_desktop.go @@ -240,6 +240,7 @@ func convRune(r rune) rune { // into the standard keycodes used by the key package. // // To get a sense of the key map, see the diagram on +// // http://boredzo.org/blog/archives/2007-05-22/virtual-key-codes func convVirtualKeyCode(vkcode uint16) key.Code { switch vkcode { diff --git a/app/doc.go b/app/doc.go index 80e21a0..02bd6db 100644 --- a/app/doc.go +++ b/app/doc.go @@ -18,7 +18,7 @@ OpenGL, audio, and other Android NDK-like APIs. An all-Go app should use this app package to initialize the app, manage its lifecycle, and receive events. -Building apps +# Building apps Apps written entirely in Go have a main function, and can be built with `gomobile build`, which directly produces runnable output for @@ -30,7 +30,7 @@ https://golang.org/x/mobile/cmd/gomobile. For detailed instructions and documentation, see https://golang.org/wiki/Mobile. -Event processing in Native Apps +# Event processing in Native Apps The Go runtime is initialized on Android when NativeActivity onCreate is called, and on iOS when the process starts. In both cases, Go init functions @@ -69,17 +69,20 @@ goroutine as other code that calls OpenGL. An event is represented by the empty interface type interface{}. Any value can be an event. Commonly used types include Event types defined by the following packages: - - golang.org/x/mobile/event/lifecycle - - golang.org/x/mobile/event/mouse - - golang.org/x/mobile/event/paint - - golang.org/x/mobile/event/size - - golang.org/x/mobile/event/touch + - golang.org/x/mobile/event/lifecycle + - golang.org/x/mobile/event/mouse + - golang.org/x/mobile/event/paint + - golang.org/x/mobile/event/size + - golang.org/x/mobile/event/touch + For example, touch.Event is the type that represents touch events. Other packages may define their own events, and send them on an app's event channel. Other packages can also register event filters, e.g. to manage resources in response to lifecycle events. Such packages should call: + app.RegisterFilter(etc) + in an init function inside that package. */ package app // import "golang.org/x/mobile/app" diff --git a/app/internal/callfn/callfn.go b/app/internal/callfn/callfn.go index 42dd028..7a3d050 100644 --- a/app/internal/callfn/callfn.go +++ b/app/internal/callfn/callfn.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build android && (arm || 386 || amd64 || arm64) // +build android // +build arm 386 amd64 arm64 diff --git a/bind/testdata/testpkg/tagged.go b/bind/testdata/testpkg/tagged.go index 69ebff0..b5fe898 100644 --- a/bind/testdata/testpkg/tagged.go +++ b/bind/testdata/testpkg/tagged.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build aaa && bbb // +build aaa,bbb // This file tests that tags work with gomobile. diff --git a/cmd/gobind/doc.go b/cmd/gobind/doc.go index 92f64ac..31155c6 100644 --- a/cmd/gobind/doc.go +++ b/cmd/gobind/doc.go @@ -11,7 +11,7 @@ generated and automatically packaged for Android or iOS by `gomobile bind`. For more details on installing and using the gomobile tool, see https://golang.org/x/mobile/cmd/gomobile. -Binding Go +# Binding Go Gobind generates target language (Java or Objective-C) bindings for each exported symbol in a Go package. The Go package you choose to @@ -24,7 +24,7 @@ package can then be _ imported into a Go program, typically built with -buildmode=c-archive for iOS or -buildmode=c-shared for Android. These details are handled by the `gomobile bind` command. -Passing Go objects to target languages +# Passing Go objects to target languages Consider a type for counting: @@ -85,7 +85,7 @@ The equivalent of calling newCounter in Go is GoMypkgNewCounter in Objective-C. The returned GoMypkgCounter* holds a reference to an underlying Go *Counter. -Passing target language objects to Go +# Passing target language objects to Go For a Go interface: @@ -125,7 +125,6 @@ The Java implementation can be used like so: Printer printer = new SysPrint(); Myfmt.printHello(printer); - For Objective-C binding, gobind generates a protocol that declares methods corresponding to Go interface's methods. @@ -154,32 +153,31 @@ The Objective-C implementation can be used like so: SysPrint* printer = [[SysPrint alloc] init]; GoMyfmtPrintHello(printer); - -Type restrictions +# Type restrictions At present, only a subset of Go types are supported. All exported symbols in the package must have types that are supported. Supported types include: - - Signed integer and floating point types. + - Signed integer and floating point types. - - String and boolean types. + - String and boolean types. - - Byte slice types. Note that byte slices are passed by reference, - and support mutation. + - Byte slice types. Note that byte slices are passed by reference, + and support mutation. - - Any function type all of whose parameters and results have - supported types. Functions must return either no results, - one result, or two results where the type of the second is - the built-in 'error' type. + - Any function type all of whose parameters and results have + supported types. Functions must return either no results, + one result, or two results where the type of the second is + the built-in 'error' type. - - Any interface type, all of whose exported methods have - supported function types. + - Any interface type, all of whose exported methods have + supported function types. - - Any struct type, all of whose exported methods have - supported function types and all of whose exported fields - have supported types. + - Any struct type, all of whose exported methods have + supported function types and all of whose exported fields + have supported types. Unexported symbols have no effect on the cross-language interface, and as such are not restricted. @@ -190,8 +188,7 @@ Go types, but this is a work in progress. Exceptions and panics are not yet supported. If either pass a language boundary, the program will exit. - -Reverse bindings +# Reverse bindings Gobind also supports accessing API from Java or Objective C from Go. Similar to how Cgo supports the magic "C" import, gobind recognizes @@ -225,7 +222,7 @@ For more details on binding the the native API, see the design proposals, https://golang.org/issues/16876 (Java) and https://golang.org/issues/17102 (Objective C). -Avoid reference cycles +# Avoid reference cycles The language bindings maintain a reference to each object that has been proxied. When a proxy object becomes unreachable, its finalizer reports @@ -246,7 +243,7 @@ We recommend that implementations of foreign interfaces do not hold references to proxies of objects. That is: if you implement a Go interface in Java, do not store an instance of Seq.Object inside it. -Further reading +# Further reading Examples can be found in http://golang.org/x/mobile/example. diff --git a/cmd/gomobile/bind_androidapp.go b/cmd/gomobile/bind_androidapp.go index 8ae9d4d..7703868 100644 --- a/cmd/gomobile/bind_androidapp.go +++ b/cmd/gomobile/bind_androidapp.go @@ -122,7 +122,7 @@ func buildSrcJar(src string) error { // These entries are directly at the root of the archive. // // AndroidManifest.xml (mandatory) -// classes.jar (mandatory) +// classes.jar (mandatory) // assets/ (optional) // jni//libgojni.so // R.txt (mandatory) diff --git a/cmd/gomobile/build.go b/cmd/gomobile/build.go index bd65f1c..a11865a 100644 --- a/cmd/gomobile/build.go +++ b/cmd/gomobile/build.go @@ -354,10 +354,11 @@ func goModTidyAt(at string, env []string) error { // parseBuildTarget parses buildTarget into 1 or more platforms and architectures. // Returns an error if buildTarget contains invalid input. // Example valid target strings: -// android -// android/arm64,android/386,android/amd64 -// ios,iossimulator,maccatalyst -// macos/amd64 +// +// android +// android/arm64,android/386,android/amd64 +// ios,iossimulator,maccatalyst +// macos/amd64 func parseBuildTarget(buildTarget string) ([]targetInfo, error) { if buildTarget == "" { return nil, fmt.Errorf(`invalid target ""`) diff --git a/cmd/gomobile/doc.go b/cmd/gomobile/doc.go index 8522dd6..10e3127 100644 --- a/cmd/gomobile/doc.go +++ b/cmd/gomobile/doc.go @@ -30,8 +30,7 @@ Commands: Use 'gomobile help [command]' for more information about that command. - -Build a library for Android and iOS +# Build a library for Android and iOS Usage: @@ -76,8 +75,7 @@ The -v flag provides verbose output, including the list of packages built. The build flags -a, -n, -x, -gcflags, -ldflags, -tags, -trimpath, and -work are shared with the build command. For documentation, see 'go help build'. - -Compile android APK and iOS app +# Compile android APK and iOS app Usage: @@ -128,15 +126,13 @@ The -v flag provides verbose output, including the list of packages built. The build flags -a, -i, -n, -x, -gcflags, -ldflags, -tags, -trimpath, and -work are shared with the build command. For documentation, see 'go help build'. - -Remove object files and cached gomobile files +# Remove object files and cached gomobile files Usage: gomobile clean -Clean removes object files and cached NDK files downloaded by gomobile init - +# Clean removes object files and cached NDK files downloaded by gomobile init Build OpenAL for Android @@ -148,8 +144,7 @@ If a OpenAL source directory is specified with -openal, init will build an Android version of OpenAL for use with gomobile build and gomobile install. - -Compile android APK and install on device +# Compile android APK and install on device Usage: @@ -164,8 +159,7 @@ The build flags -a, -i, -n, -x, -gcflags, -ldflags, -tags, -trimpath, and -work shared with the build command. For documentation, see 'go help build'. - -Print version +# Print version Usage: diff --git a/event/lifecycle/lifecycle.go b/event/lifecycle/lifecycle.go index 9a5f54e..4c58858 100644 --- a/event/lifecycle/lifecycle.go +++ b/event/lifecycle/lifecycle.go @@ -59,9 +59,10 @@ func (e Event) String() string { } // Crosses reports whether the transition from From to To crosses the stage s: -// - It returns CrossOn if it does, and the lifecycle change is positive. -// - It returns CrossOff if it does, and the lifecycle change is negative. -// - Otherwise, it returns CrossNone. +// - It returns CrossOn if it does, and the lifecycle change is positive. +// - It returns CrossOff if it does, and the lifecycle change is negative. +// - Otherwise, it returns CrossNone. +// // See the documentation for Stage for more discussion of positive and negative // crosses. func (e Event) Crosses(s Stage) Cross { diff --git a/event/paint/paint.go b/event/paint/paint.go index b7b4113..0f24b1a 100644 --- a/event/paint/paint.go +++ b/event/paint/paint.go @@ -9,7 +9,7 @@ package paint // import "golang.org/x/mobile/event/paint" // Event indicates that the app is ready to paint the next frame of the GUI. // -//A frame is completed by calling the App's Publish method. +// A frame is completed by calling the App's Publish method. type Event struct { // External is true for paint events sent by the screen driver. // diff --git a/example/basic/main.go b/example/basic/main.go index 697fe21..94932db 100644 --- a/example/basic/main.go +++ b/example/basic/main.go @@ -13,19 +13,20 @@ // // Get the basic example and use gomobile to build or install it on your device. // -// $ go get -d golang.org/x/mobile/example/basic -// $ gomobile build golang.org/x/mobile/example/basic # will build an APK +// $ go get -d golang.org/x/mobile/example/basic +// $ gomobile build golang.org/x/mobile/example/basic # will build an APK // -// # plug your Android device to your computer or start an Android emulator. -// # if you have adb installed on your machine, use gomobile install to -// # build and deploy the APK to an Android target. -// $ gomobile install golang.org/x/mobile/example/basic +// # plug your Android device to your computer or start an Android emulator. +// # if you have adb installed on your machine, use gomobile install to +// # build and deploy the APK to an Android target. +// $ gomobile install golang.org/x/mobile/example/basic // // Switch to your device or emulator to start the Basic application from // the launcher. // You can also run the application on your desktop by running the command // below. (Note: It currently doesn't work on Windows.) -// $ go install golang.org/x/mobile/example/basic && basic +// +// $ go install golang.org/x/mobile/example/basic && basic package main import ( diff --git a/example/network/main.go b/example/network/main.go index 8375eb0..4b23cbe 100644 --- a/example/network/main.go +++ b/example/network/main.go @@ -11,7 +11,7 @@ // In order to access the network from the Android app, its AndroidManifest.xml // file must include the permission to access the network. // -// http://developer.android.com/guide/topics/manifest/manifest-intro.html#perms +// http://developer.android.com/guide/topics/manifest/manifest-intro.html#perms // // The gomobile tool auto-generates a default AndroidManifest file by default // unless the package directory contains the AndroidManifest.xml. Users can @@ -25,19 +25,20 @@ // // Get the network example and use gomobile to build or install it on your device. // -// $ go get -d golang.org/x/mobile/example/network -// $ gomobile build golang.org/x/mobile/example/network # will build an APK +// $ go get -d golang.org/x/mobile/example/network +// $ gomobile build golang.org/x/mobile/example/network # will build an APK // -// # plug your Android device to your computer or start an Android emulator. -// # if you have adb installed on your machine, use gomobile install to -// # build and deploy the APK to an Android target. -// $ gomobile install golang.org/x/mobile/example/network +// # plug your Android device to your computer or start an Android emulator. +// # if you have adb installed on your machine, use gomobile install to +// # build and deploy the APK to an Android target. +// $ gomobile install golang.org/x/mobile/example/network // // Switch to your device or emulator to start the network application from // the launcher. // You can also run the application on your desktop by running the command // below. (Note: It currently doesn't work on Windows.) -// $ go install golang.org/x/mobile/example/network && network +// +// $ go install golang.org/x/mobile/example/network && network package main import ( diff --git a/exp/audio/al/al.go b/exp/audio/al/al.go index bcddeef..b2396a5 100644 --- a/exp/audio/al/al.go +++ b/exp/audio/al/al.go @@ -17,7 +17,7 @@ // On Ubuntu 14.04 'Trusty', you may have to install this library // by running the command below. // -// sudo apt-get install libopenal-dev +// sudo apt-get install libopenal-dev // // When compiled for Android, this package uses OpenAL Soft. Please add its // license file to the open source notices of your application. diff --git a/exp/f32/f32.go b/exp/f32/f32.go index d794398..59e1b65 100644 --- a/exp/f32/f32.go +++ b/exp/f32/f32.go @@ -18,7 +18,7 @@ // It is safe to use the destination address as the left-hand side, // that is, dst *= rhs is dst.Mul(dst, rhs). // -// WARNING +// # WARNING // // The interface to this package is not stable. It will change considerably. // Only use functions that provide package documentation. Semantics are diff --git a/exp/f32/mat4.go b/exp/f32/mat4.go index 75d3a59..ffa1a8f 100644 --- a/exp/f32/mat4.go +++ b/exp/f32/mat4.go @@ -92,6 +92,7 @@ func (m *Mat4) Perspective(fov Radian, aspect, near, far float32) { // Scale sets m to be a scale followed by p. // It is equivalent to +// // m.Mul(p, &Mat4{ // {x, 0, 0, 0}, // {0, y, 0, 0}, @@ -119,6 +120,7 @@ func (m *Mat4) Scale(p *Mat4, x, y, z float32) { // Translate sets m to be a translation followed by p. // It is equivalent to +// // m.Mul(p, &Mat4{ // {1, 0, 0, x}, // {0, 1, 0, y}, diff --git a/exp/sprite/portable/portable.go b/exp/sprite/portable/portable.go index 66b9f79..28925d1 100644 --- a/exp/sprite/portable/portable.go +++ b/exp/sprite/portable/portable.go @@ -154,14 +154,14 @@ func (e *engine) Release() {} // affine draws each pixel of dst using bilinear interpolation of the // affine-transformed position in src. This is equivalent to: // -// for each (x,y) in dst: -// dst(x,y) = bilinear interpolation of src(a*(x,y)) +// for each (x,y) in dst: +// dst(x,y) = bilinear interpolation of src(a*(x,y)) // // While this is the simpler implementation, it can be counter- // intuitive as an affine transformation is usually described in terms // of the source, not the destination. For example, a scale transform // -// Affine{{2, 0, 0}, {0, 2, 0}} +// Affine{{2, 0, 0}, {0, 2, 0}} // // will produce a dst that is half the size of src. To perform a // traditional affine transform, use the inverse of the affine matrix. diff --git a/gl/doc.go b/gl/doc.go index 1eb1d77..880d5f9 100644 --- a/gl/doc.go +++ b/gl/doc.go @@ -22,7 +22,7 @@ https://www.khronos.org/opengles/sdk/docs/man/ One notable departure from the C API is the introduction of types to represent common uses of GLint: Texture, Surface, Buffer, etc. -Debug Logging +# Debug Logging A tracing version of the OpenGL bindings is behind the `gldebug` build tag. It acts as a simplified version of apitrace. Build your Go binary diff --git a/internal/binres/binres.go b/internal/binres/binres.go index 8673063..78b874f 100644 --- a/internal/binres/binres.go +++ b/internal/binres/binres.go @@ -12,9 +12,9 @@ // sent to unmarshalling. This allows tests to validate each struct representation // of the binary format as follows: // -// * unmarshal the output of aapt -// * marshal the struct representation -// * perform byte-to-byte comparison with aapt output per chunk header and body +// - unmarshal the output of aapt +// - marshal the struct representation +// - perform byte-to-byte comparison with aapt output per chunk header and body // // This process should strive to make structs idiomatic to make parsing xml text // into structs trivial. @@ -22,9 +22,9 @@ // Once the struct representation is validated, tests for parsing xml text // into structs can become self-referential as the following holds true: // -// * the unmarshalled input of aapt output is the only valid target -// * the unmarshalled input of xml text may be compared to the unmarshalled -// input of aapt output to identify errors, e.g. text-trims, wrong flags, etc +// - the unmarshalled input of aapt output is the only valid target +// - the unmarshalled input of xml text may be compared to the unmarshalled +// input of aapt output to identify errors, e.g. text-trims, wrong flags, etc // // This provides validation, byte-for-byte, for producing binary xml resources. // @@ -34,11 +34,11 @@ // // A simple view of binary xml document structure: // -// XML -// Pool -// Map -// Namespace -// [...node] +// XML +// Pool +// Map +// Namespace +// [...node] // // Additional resources: // https://android.googlesource.com/platform/frameworks/base/+/master/libs/androidfw/include/androidfw/ResourceTypes.h diff --git a/internal/binres/pool.go b/internal/binres/pool.go index 5e5958d..273e94c 100644 --- a/internal/binres/pool.go +++ b/internal/binres/pool.go @@ -25,28 +25,31 @@ func (ref PoolRef) Resolve(pl *Pool) string { // Pool is a container for string and style span collections. // // Pool has the following structure marshalled: -// chunkHeader -// uint32 number of strings in this pool -// uint32 number of style spans in pool -// uint32 SortedFlag, UTF8Flag -// uint32 index of string data from header -// uint32 index of style data from header -// []uint32 string indices starting at zero -// []uint16 or []uint8 concatenation of string entries +// +// chunkHeader +// uint32 number of strings in this pool +// uint32 number of style spans in pool +// uint32 SortedFlag, UTF8Flag +// uint32 index of string data from header +// uint32 index of style data from header +// []uint32 string indices starting at zero +// []uint16 or []uint8 concatenation of string entries // // UTF-16 entries are as follows: -// uint16 string length, exclusive -// uint16 [optional] low word if high bit of length set -// [n]byte data -// uint16 0x0000 terminator +// +// uint16 string length, exclusive +// uint16 [optional] low word if high bit of length set +// [n]byte data +// uint16 0x0000 terminator // // UTF-8 entries are as follows: -// uint8 character length, exclusive -// uint8 [optional] low word if high bit of character length set -// uint8 byte length, exclusive -// uint8 [optional] low word if high bit of byte length set -// [n]byte data -// uint8 0x00 terminator +// +// uint8 character length, exclusive +// uint8 [optional] low word if high bit of character length set +// uint8 byte length, exclusive +// uint8 [optional] low word if high bit of byte length set +// [n]byte data +// uint8 0x00 terminator type Pool struct { chunkHeader strings []string diff --git a/internal/binres/table.go b/internal/binres/table.go index 6c80aff..304736d 100644 --- a/internal/binres/table.go +++ b/internal/binres/table.go @@ -22,10 +22,11 @@ type TableRef uint32 // Resolve returns the Entry of TableRef in the given table. // // A TableRef is structured as follows: -// 0xpptteeee -// pp: package index -// tt: type spec index in package -// eeee: entry index in type spec +// +// 0xpptteeee +// pp: package index +// tt: type spec index in package +// eeee: entry index in type spec // // The package and type spec values start at 1 for the first item, // to help catch cases where they have not been supplied. @@ -127,8 +128,10 @@ func OpenTable() (*Table, error) { // indices. // // For example: -// tbl.SpecByName("@android:style/Theme.NoTitleBar") -// tbl.SpecByName("style") +// +// tbl.SpecByName("@android:style/Theme.NoTitleBar") +// tbl.SpecByName("style") +// // Both locate the spec by name "style". func (tbl *Table) SpecByName(name string) (int, *Package, int, *TypeSpec, error) { n := strings.TrimPrefix(name, "@android:") diff --git a/internal/importers/ast.go b/internal/importers/ast.go index b9e36ee..64da4a1 100644 --- a/internal/importers/ast.go +++ b/internal/importers/ast.go @@ -7,15 +7,17 @@ // It is used by the language specific importers to determine the set of // wrapper types to be generated. // -// For example, in the Go file +// # For example, in the Go file // // package javaprogram // // import "Java/java/lang" // // func F() { -// o := lang.Object.New() -// ... +// +// o := lang.Object.New() +// ... +// // } // // the java importer uses this package to determine that the "java/lang" @@ -39,7 +41,7 @@ import ( // References is the result of analyzing a Go file or set of Go packages. // -// For example, the Go file +// # For example, the Go file // // package pkg // @@ -124,7 +126,9 @@ func AnalyzePackages(pkgs []*packages.Package, pkgPrefix string) (*References, e // import "Prefix/some/Package" // // type T struct { -// Package.Class +// +// Package.Class +// // } func (v *refsSaver) findEmbeddingStructs(pkgpath string, pkg *ast.Package) { var names []string diff --git a/internal/importers/java/java.go b/internal/importers/java/java.go index 3a26dfb..5a813a1 100644 --- a/internal/importers/java/java.go +++ b/internal/importers/java/java.go @@ -178,16 +178,17 @@ func javapPath() (string, error) { // // Compiled from "System.java" // public final class java.lang.System { -// public static final java.io.InputStream in; -// descriptor: Ljava/io/InputStream; -// public static final java.io.PrintStream out; -// descriptor: Ljava/io/PrintStream; -// public static final java.io.PrintStream err; -// descriptor: Ljava/io/PrintStream; -// public static void setIn(java.io.InputStream); -// descriptor: (Ljava/io/InputStream;)V // -// ... +// public static final java.io.InputStream in; +// descriptor: Ljava/io/InputStream; +// public static final java.io.PrintStream out; +// descriptor: Ljava/io/PrintStream; +// public static final java.io.PrintStream err; +// descriptor: Ljava/io/PrintStream; +// public static void setIn(java.io.InputStream); +// descriptor: (Ljava/io/InputStream;)V +// +// ... // // } func (j *Importer) Import(refs *importers.References) ([]*Class, error) { @@ -409,27 +410,27 @@ func combineSigs(clsMap map[string]*Class, sigs ...CommonSig) CommonSig { // // For example, the class // -// class A { -// void f(); -// } +// class A { +// void f(); +// } // // is by itself represented by the Go interface // -// type A interface { -// f() -// } +// type A interface { +// f() +// } // // However, if class // -// class B extends A { -// void f(int); -// } +// class B extends A { +// void f(int); +// } // // is also imported, it will be represented as // -// type B interface { -// f(...int32) -// } +// type B interface { +// f(...int32) +// } // // To make Go B assignable to Go A, the signature of A's f must // be updated to f(...int32) as well.