MCPcopy Create free account
hub / github.com/golang/mobile / genCRetClear

Method genCRetClear

bind/genjava.go:878–894  ·  view source on GitHub ↗

genCRetClear clears the result value from a JNI call if an exception was raised.

(varName string, t types.Type, exc string)

Source from the content-addressed store, hash-verified

876// genCRetClear clears the result value from a JNI call if an exception was
877// raised.
878func (g *JavaGen) genCRetClear(varName string, t types.Type, exc string) {
879 g.Printf("if (%s != NULL) {\n", exc)
880 g.Indent()
881 switch t := t.(type) {
882 case *types.Basic:
883 switch t.Kind() {
884 case types.String:
885 g.Printf("%s = NULL;\n", varName)
886 default:
887 g.Printf("%s = 0;\n", varName)
888 }
889 case *types.Slice, *types.Named, *types.Pointer:
890 g.Printf("%s = NULL;\n", varName)
891 }
892 g.Outdent()
893 g.Printf("}\n")
894}
895
896func (g *JavaGen) genJavaToC(varName string, t types.Type, mode varMode) {
897 switch t := types.Unalias(t).(type) {

Callers 1

Calls 3

PrintfMethod · 0.80
IndentMethod · 0.80
OutdentMethod · 0.80

Tested by

no test coverage detected