浏览代码

Consistent C function naming

/3.1
Tim Mowrer 6 年前
当前提交
7d32af86
共有 5 个文件被更改,包括 21 次插入22 次删除
  1. 10
      Assets/Scripts/Multipeer/MCSession.cs
  2. 8
      Assets/Scripts/Multipeer/NSString.cs
  3. 2
      Assets/Scripts/Multipeer/NativeApi.cs
  4. 15
      Assets/Scripts/Multipeer/NativeCode/MultipeerDelegate-C-Bridge.m
  5. 8
      Assets/Scripts/Multipeer/NativeCode/NSString-C-Bridge.m

10
Assets/Scripts/Multipeer/MCSession.cs


[DllImport("__Internal", EntryPoint="UnityMC_Delegate_initWithName")]
static extern IntPtr InitWithName(NSString name, NSString serviceType);
[DllImport("__Internal", EntryPoint="UnityMC_Delegate_ReceivedDataQueueSize")]
[DllImport("__Internal", EntryPoint="UnityMC_Delegate_receivedDataQueueSize")]
[DllImport("__Internal", EntryPoint="UnityMC_Delegate_DequeueReceivedData")]
[DllImport("__Internal", EntryPoint="UnityMC_Delegate_dequeueReceivedData")]
[DllImport("__Internal", EntryPoint="UnityMC_Delegate_ConnectedPeerCount")]
[DllImport("__Internal", EntryPoint="UnityMC_Delegate_connectedPeerCount")]
[DllImport("__Internal", EntryPoint="UnityMC_Delegate_SetEnabled")]
[DllImport("__Internal", EntryPoint="UnityMC_Delegate_setEnabled")]
[DllImport("__Internal", EntryPoint="UnityMC_Delegate_GetEnabled")]
[DllImport("__Internal", EntryPoint="UnityMC_Delegate_getEnabled")]
static extern bool GetEnabled(MCSession self);
}
}

8
Assets/Scripts/Multipeer/NSString.cs


public static bool operator==(NSString lhs, NSString rhs) => lhs.Equals(rhs);
public static bool operator!=(NSString lhs, NSString rhs) => !lhs.Equals(rhs);
[DllImport("__Internal", EntryPoint="UnityMultipeer_NSString_createWithString")]
[DllImport("__Internal", EntryPoint="UnityMC_NSString_createWithString")]
[DllImport("__Internal", EntryPoint="UnityMultipeer_NSString_lengthOfBytesUsingEncoding")]
[DllImport("__Internal", EntryPoint="UnityMC_NSString_lengthOfBytesUsingEncoding")]
[DllImport("__Internal", EntryPoint="UnityMultipeer_NSString_getLength")]
[DllImport("__Internal", EntryPoint="UnityMC_NSString_getLength")]
[DllImport("__Internal", EntryPoint="UnityMultipeer_NSString_getBytes")]
[DllImport("__Internal", EntryPoint="UnityMC_NSString_getBytes")]
static extern unsafe bool GetBytes(NSString self, void* buffer, int length);
[DllImport("__Internal", EntryPoint="UnityMC_NSString_serialize")]

2
Assets/Scripts/Multipeer/NativeApi.cs


ptr = IntPtr.Zero;
}
[DllImport("__Internal", EntryPoint="UnityMultipeer_CFRelease")]
[DllImport("__Internal", EntryPoint="UnityMC_CFRelease")]
public static extern void CFRelease(IntPtr ptr);
}
}

15
Assets/Scripts/Multipeer/NativeCode/MultipeerDelegate-C-Bridge.m


return (__bridge_retained void*)error;
}
int UnityMC_Delegate_ReceivedDataQueueSize(void* self)
int UnityMC_Delegate_receivedDataQueueSize(void* self)
void* UnityMC_Delegate_DequeueReceivedData(void* self)
void* UnityMC_Delegate_dequeueReceivedData(void* self)
int UnityMC_Delegate_ConnectedPeerCount(void* self)
int UnityMC_Delegate_connectedPeerCount(void* self)
void UnityMC_Delegate_SetEnabled(void* self, bool enabled)
void UnityMC_Delegate_setEnabled(void* self, bool enabled)
bool UnityMC_Delegate_GetEnabled(void* self)
bool UnityMC_Delegate_getEnabled(void* self)
void UnityMultipeer_CFRelease(void* ptr)
void UnityMC_CFRelease(void* ptr)
{
if (ptr)
{

8
Assets/Scripts/Multipeer/NativeCode/NSString-C-Bridge.m


#import <Foundation/Foundation.h>
int UnityMultipeer_NSString_lengthOfBytesUsingEncoding(void* self)
int UnityMC_NSString_lengthOfBytesUsingEncoding(void* self)
{
if (self == NULL)
return 0;

}
bool UnityMultipeer_NSString_getBytes(void* self, void* buffer, int length)
bool UnityMC_NSString_getBytes(void* self, void* buffer, int length)
{
NSString* string = (__bridge NSString*)self;
const NSRange range = NSMakeRange(0, string.length);

remainingRange:NULL];
}
int UnityMultipeer_NSString_getLength(void* self)
int UnityMC_NSString_getLength(void* self)
void* UnityMultipeer_NSString_createWithString(void* bytes, int length)
void* UnityMC_NSString_createWithString(void* bytes, int length)
{
NSString* string = [[NSString alloc] initWithBytes: bytes
length: 2 * length

正在加载...
取消
保存