objcw.go 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // Copyright 2014 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 objc
  5. import (
  6. "ObjC/Foundation"
  7. "ObjC/Foundation/NSMutableString"
  8. "ObjC/NetworkExtension/NEPacket"
  9. "ObjC/UIKit"
  10. )
  11. type GoNSDate struct {
  12. Foundation.NSDate
  13. this Foundation.NSDate
  14. }
  15. func (d *GoNSDate) Hash(this Foundation.NSDate) int {
  16. return 0
  17. }
  18. type GoNSObject struct {
  19. C Foundation.NSObjectC // The class
  20. P Foundation.NSObjectP // The protocol
  21. }
  22. func (o *GoNSObject) Description(this Foundation.NSObjectC) string {
  23. return ""
  24. }
  25. func DupNSDate(date Foundation.NSDate) Foundation.NSDate {
  26. return date
  27. }
  28. type GoUIResponder struct {
  29. UIKit.UIResponder
  30. }
  31. func (r *GoUIResponder) PressesBegan(_ Foundation.NSSet, _ UIKit.UIPressesEvent) {
  32. }
  33. const NSUTF8StringEncoding = 8
  34. func CreateReadNSMutableString() {
  35. myData := []byte{'A', 'B'}
  36. // Test byte slices. Use NSMutableString because NSString is
  37. // represented as Go strings in bindings.
  38. // Pass slice from Go to native.
  39. mString := NSMutableString.NewWithData(myData, uint(NSUTF8StringEncoding))
  40. // Pass slice from native to Go.
  41. _ = mString.DataUsingEncoding(uint(NSUTF8StringEncoding))
  42. }
  43. // From <sys/socket.h>
  44. const PF_INET = 2
  45. func CallUcharFunction() {
  46. _ = NEPacket.NewWithData(nil, uint8(PF_INET))
  47. }