github.com/F4RD1N/gomobile@v1.0.1/bind/testdata/testpkg/objcpkg/classes.go (about) 1 // Copyright 2016 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package objcpkg 6 7 import ( 8 "ObjC/Foundation" 9 gopkg "ObjC/Objcpkg" 10 "ObjC/UIKit" 11 ) 12 13 const ( 14 DescriptionStr = "Descriptrion from Go" 15 Hash = 42 16 ) 17 18 type GoNSDate struct { 19 Foundation.NSDate 20 } 21 22 func (d *GoNSDate) Hash(self gopkg.GoNSDate) int { 23 return Hash 24 } 25 26 func (d *GoNSDate) Description(self gopkg.GoNSDate) string { 27 // Test self call 28 if h := self.Hash(); h != Hash { 29 panic("hash mismatch") 30 } 31 return DescriptionStr 32 } 33 34 func (d *GoNSDate) GetSelf(self gopkg.GoNSDate) Foundation.NSDate { 35 return self 36 } 37 38 func NewGoNSDate() *GoNSDate { 39 return new(GoNSDate) 40 } 41 42 type GoNSObject struct { 43 C Foundation.NSObjectC // The class 44 P Foundation.NSObjectP // The protocol 45 UseSelf bool 46 } 47 48 func (o *GoNSObject) Description(self gopkg.GoNSObject) string { 49 if o.UseSelf { 50 return DescriptionStr 51 } else { 52 return self.Super().Description() 53 } 54 } 55 56 func DupNSDate(date Foundation.NSDate) Foundation.NSDate { 57 return date 58 } 59 60 type GoUIResponder struct { 61 UIKit.UIResponder 62 Called bool 63 } 64 65 func (r *GoUIResponder) PressesBegan(_ Foundation.NSSet, _ UIKit.UIPressesEvent) { 66 r.Called = true 67 } 68 69 // Check that implicitly referenced types are wrapped. 70 func implicitType(r UIKit.UIResponder) { 71 r.MotionBegan(0, nil) 72 }