classes.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. package objcpkg
  5. import (
  6. "ObjC/Foundation"
  7. gopkg "ObjC/Objcpkg"
  8. "ObjC/UIKit"
  9. )
  10. const (
  11. DescriptionStr = "Descriptrion from Go"
  12. Hash = 42
  13. )
  14. type GoNSDate struct {
  15. Foundation.NSDate
  16. }
  17. func (d *GoNSDate) Hash(self gopkg.GoNSDate) int {
  18. return Hash
  19. }
  20. func (d *GoNSDate) Description(self gopkg.GoNSDate) string {
  21. // Test self call
  22. if h := self.Hash(); h != Hash {
  23. panic("hash mismatch")
  24. }
  25. return DescriptionStr
  26. }
  27. func (d *GoNSDate) GetSelf(self gopkg.GoNSDate) Foundation.NSDate {
  28. return self
  29. }
  30. func NewGoNSDate() *GoNSDate {
  31. return new(GoNSDate)
  32. }
  33. type GoNSObject struct {
  34. C Foundation.NSObjectC // The class
  35. P Foundation.NSObjectP // The protocol
  36. UseSelf bool
  37. }
  38. func (o *GoNSObject) Description(self gopkg.GoNSObject) string {
  39. if o.UseSelf {
  40. return DescriptionStr
  41. } else {
  42. return self.Super().Description()
  43. }
  44. }
  45. func DupNSDate(date Foundation.NSDate) Foundation.NSDate {
  46. return date
  47. }
  48. type GoUIResponder struct {
  49. UIKit.UIResponder
  50. Called bool
  51. }
  52. func (r *GoUIResponder) PressesBegan(_ Foundation.NSSet, _ UIKit.UIPressesEvent) {
  53. r.Called = true
  54. }
  55. // Check that implicitly referenced types are wrapped.
  56. func implicitType(r UIKit.UIResponder) {
  57. r.MotionBegan(0, nil)
  58. }