github.com/F4RD1N/gomobile@v1.0.1/bind/objc/seq_darwin.h (about)

     1  // Copyright 2015 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  #ifndef __GO_SEQ_DARWIN_HDR__
     6  #define __GO_SEQ_DARWIN_HDR__
     7  
     8  #include <Foundation/Foundation.h>
     9  #include "ref.h"
    10  #include "Universe.objc.h"
    11  
    12  #ifdef DEBUG
    13  #define LOG_DEBUG(...) NSLog(__VA_ARGS__);
    14  #else
    15  #define LOG_DEBUG(...) ;
    16  #endif
    17  
    18  #define LOG_INFO(...) NSLog(__VA_ARGS__);
    19  #define LOG_FATAL(...)                                                         \
    20    {                                                                            \
    21      NSLog(__VA_ARGS__);                                                        \
    22      @throw                                                                     \
    23          [NSException exceptionWithName:NSInternalInconsistencyException        \
    24                                  reason:[NSString stringWithFormat:__VA_ARGS__] \
    25                                userInfo:NULL];                                  \
    26    }
    27  
    28  // Platform specific types
    29  typedef struct nstring {
    30  	void *ptr;
    31  	int len;
    32  } nstring;
    33  typedef struct nbyteslice {
    34  	void *ptr;
    35  	int len;
    36  } nbyteslice;
    37  typedef int nint;
    38  
    39  extern void init_seq();
    40  // go_seq_dec_ref decrements the reference count for the
    41  // specified refnum. It is called from Go from a finalizer.
    42  extern void go_seq_dec_ref(int32_t refnum);
    43  // go_seq_inc_ref increments the reference count for the
    44  // specified refnum. It is called from Go just before converting
    45  // a proxy to its refnum.
    46  extern void go_seq_inc_ref(int32_t refnum);
    47  
    48  extern int32_t go_seq_to_refnum(id obj);
    49  // go_seq_go_to_refnum is a special case of go_seq_to_refnum
    50  extern int32_t go_seq_go_to_refnum(GoSeqRef *ref);
    51  
    52  extern GoSeqRef *go_seq_from_refnum(int32_t refnum);
    53  // go_seq_objc_from_refnum is a special case of go_seq_from_refnum for
    54  // Objective-C objects that implement a Go interface.
    55  extern id go_seq_objc_from_refnum(int32_t refnum);
    56  
    57  extern nbyteslice go_seq_from_objc_bytearray(NSData *data, int copy);
    58  extern nstring go_seq_from_objc_string(NSString *s);
    59  
    60  extern NSData *go_seq_to_objc_bytearray(nbyteslice, int copy);
    61  extern NSString *go_seq_to_objc_string(nstring str);
    62  
    63  #endif // __GO_SEQ_DARWIN_HDR__