mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-01-19 20:24:49 +00:00
Merge pull request #1907 from elfprince13/osxDedeprecation
OSX de-deprecation (profiler and macFileIO)
This commit is contained in:
commit
87c9fce380
|
|
@ -491,10 +491,11 @@ template<class T> T ReservedSocketList<T>::resolve(NetSocket socketToResolve)
|
|||
EntryType &entry = mSocketList[socketToResolve.getHandle()];
|
||||
return entry.used ? entry.value : -1;
|
||||
}
|
||||
ConnectionNotifyEvent* Net::smConnectionNotify = NULL;
|
||||
ConnectionAcceptedEvent* Net::smConnectionAccept = NULL;
|
||||
ConnectionReceiveEvent* Net::smConnectionReceive = NULL;
|
||||
PacketReceiveEvent* Net::smPacketReceive = NULL;
|
||||
|
||||
static ConnectionNotifyEvent* smConnectionNotify = NULL;
|
||||
static ConnectionAcceptedEvent* smConnectionAccept = NULL;
|
||||
static ConnectionReceiveEvent* smConnectionReceive = NULL;
|
||||
static PacketReceiveEvent* smPacketReceive = NULL;
|
||||
|
||||
ConnectionNotifyEvent& Net::getConnectionNotifyEvent()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -220,7 +220,6 @@ struct Net
|
|||
static ConnectionReceiveEvent* smConnectionReceive;
|
||||
static PacketReceiveEvent* smPacketReceive;
|
||||
|
||||
|
||||
static bool init();
|
||||
static void shutdown();
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
#endif
|
||||
|
||||
#if defined(TORQUE_OS_MAC)
|
||||
#include <CoreServices/CoreServices.h> // For high resolution timer
|
||||
#include <mach/mach_time.h>
|
||||
#endif
|
||||
|
||||
#include "core/stream/fileStream.h"
|
||||
|
|
@ -54,9 +54,9 @@ Profiler *gProfiler = NULL;
|
|||
Vector<StringTableEntry> gProfilerNodeStack;
|
||||
#define TORQUE_PROFILE_AT_ENGINE_START true
|
||||
#define PROFILER_DEBUG_PUSH_NODE( nodename ) \
|
||||
gProfilerNodeStack.push_back( nodename );
|
||||
gProfilerNodeStack.push_back( nodename );
|
||||
#define PROFILER_DEBUG_POP_NODE() \
|
||||
gProfilerNodeStack.pop_back();
|
||||
gProfilerNodeStack.pop_back();
|
||||
#else
|
||||
#define TORQUE_PROFILE_AT_ENGINE_START false
|
||||
#define PROFILER_DEBUG_PUSH_NODE( nodename ) ;
|
||||
|
|
@ -135,20 +135,26 @@ U32 endHighResolutionTimer(U32 time[2])
|
|||
|
||||
|
||||
void startHighResolutionTimer(U32 time[2]) {
|
||||
UnsignedWide t;
|
||||
Microseconds(&t);
|
||||
time[0] = t.lo;
|
||||
time[1] = t.hi;
|
||||
U64 now = mach_absolute_time();
|
||||
AssertFatal(sizeof(U32[2]) == sizeof(U64), "Can't pack mach_absolute_time into U32[2]");
|
||||
memcpy(time, &now, sizeof(U64));
|
||||
}
|
||||
|
||||
U32 endHighResolutionTimer(U32 time[2]) {
|
||||
UnsignedWide t;
|
||||
Microseconds(&t);
|
||||
return t.lo - time[0];
|
||||
// given that we're returning a 32 bit integer, and this is unsigned subtraction...
|
||||
// it will just wrap around, we don't need the upper word of the time.
|
||||
// NOTE: the code assumes that more than 3 hrs will not go by between calls to startHighResolutionTimer() and endHighResolutionTimer().
|
||||
// I mean... that damn well better not happen anyway.
|
||||
static mach_timebase_info_data_t sTimebaseInfo = {0, 0};
|
||||
|
||||
U64 now = mach_absolute_time();
|
||||
AssertFatal(sizeof(U32[2]) == sizeof(U64), "Can't pack mach_absolute_time into U32[2]");
|
||||
U64 then;
|
||||
memcpy(&then, time, sizeof(U64));
|
||||
|
||||
if(sTimebaseInfo.denom == 0){
|
||||
mach_timebase_info(&sTimebaseInfo);
|
||||
}
|
||||
// Handle the micros/nanos conversion first, because shedding a few bits is better than overflowing.
|
||||
U64 elapsedMicros = ((now - then) / 1000) * sTimebaseInfo.numer / sTimebaseInfo.denom;
|
||||
|
||||
return (U32)elapsedMicros; // Just truncate, and hope we didn't overflow
|
||||
}
|
||||
|
||||
#else
|
||||
|
|
|
|||
|
|
@ -76,8 +76,8 @@ TEST(Net, TCPRequest)
|
|||
handler.mDataReceived = 0;
|
||||
|
||||
// Hook into the signals.
|
||||
Net::smConnectionNotify ->notify(&handler, &TcpHandle::notify);
|
||||
Net::smConnectionReceive->notify(&handler, &TcpHandle::receive);
|
||||
Net::smConnectionNotify .notify(&handler, &TcpHandle::notify);
|
||||
Net::smConnectionReceive.notify(&handler, &TcpHandle::receive);
|
||||
|
||||
// Open a TCP connection to garagegames.com
|
||||
handler.mSocket = Net::openConnectTo("72.246.107.193:80");
|
||||
|
|
@ -85,8 +85,8 @@ TEST(Net, TCPRequest)
|
|||
while(Process::processEvents() && (Platform::getRealMilliseconds() < limit) ) {}
|
||||
|
||||
// Unhook from the signals.
|
||||
Net::smConnectionNotify ->remove(&handler, &TcpHandle::notify);
|
||||
Net::smConnectionReceive->remove(&handler, &TcpHandle::receive);
|
||||
Net::smConnectionNotify .remove(&handler, &TcpHandle::notify);
|
||||
Net::smConnectionReceive.remove(&handler, &TcpHandle::receive);
|
||||
|
||||
EXPECT_GT(handler.mDataReceived, 0)
|
||||
<< "Didn't get any data back!";
|
||||
|
|
@ -139,8 +139,8 @@ struct JournalHandle
|
|||
mDataReceived = 0;
|
||||
|
||||
// Hook into the signals.
|
||||
Net::smConnectionNotify ->notify(this, &JournalHandle::notify);
|
||||
Net::smConnectionReceive->notify(this, &JournalHandle::receive);
|
||||
Net::smConnectionNotify .notify(this, &JournalHandle::notify);
|
||||
Net::smConnectionReceive.notify(this, &JournalHandle::receive);
|
||||
|
||||
// Open a TCP connection to garagegames.com
|
||||
mSocket = Net::openConnectTo("72.246.107.193:80");
|
||||
|
|
@ -149,8 +149,8 @@ struct JournalHandle
|
|||
while(Process::processEvents()) {}
|
||||
|
||||
// Unhook from the signals.
|
||||
Net::smConnectionNotify ->remove(this, &JournalHandle::notify);
|
||||
Net::smConnectionReceive->remove(this, &JournalHandle::receive);
|
||||
Net::smConnectionNotify .remove(this, &JournalHandle::notify);
|
||||
Net::smConnectionReceive.remove(this, &JournalHandle::receive);
|
||||
|
||||
EXPECT_GT(mDataReceived, 0)
|
||||
<< "Didn't get any data back!";
|
||||
|
|
|
|||
|
|
@ -68,11 +68,14 @@ bool dFileTouch(const char *path)
|
|||
//-----------------------------------------------------------------------------
|
||||
bool dPathCopy(const char* source, const char* dest, bool nooverwrite)
|
||||
{
|
||||
NSFileManager *manager = [NSFileManager defaultManager];
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
if(source == NULL || dest == NULL)
|
||||
return false;
|
||||
|
||||
NSString *nsource = [[NSString stringWithUTF8String:source] stringByStandardizingPath];
|
||||
NSString *ndest = [[NSString stringWithUTF8String:dest] stringByStandardizingPath];
|
||||
@autoreleasepool {
|
||||
NSFileManager *manager = [NSFileManager defaultManager];
|
||||
|
||||
NSString *nsource = [manager stringWithFileSystemRepresentation:source length:dStrlen(source)];
|
||||
NSString *ndest = [manager stringWithFileSystemRepresentation:dest length:dStrlen(dest)];
|
||||
NSString *ndestFolder = [ndest stringByDeletingLastPathComponent];
|
||||
|
||||
if(! [manager fileExistsAtPath:nsource])
|
||||
|
|
@ -89,8 +92,7 @@ bool dPathCopy(const char* source, const char* dest, bool nooverwrite)
|
|||
return false;
|
||||
}
|
||||
Con::warnf("Deleting files at path: %s", dest);
|
||||
bool deleted = [manager removeFileAtPath:ndest handler:nil];
|
||||
if(!deleted)
|
||||
if(![manager removeItemAtPath:ndest error:nil] || [manager fileExistsAtPath:ndest])
|
||||
{
|
||||
Con::errorf("Copy failed! Could not delete files at path: %s", dest);
|
||||
return false;
|
||||
|
|
@ -103,10 +105,16 @@ bool dPathCopy(const char* source, const char* dest, bool nooverwrite)
|
|||
Platform::createPath([ndestFolder UTF8String]);
|
||||
}
|
||||
|
||||
bool ret = [manager copyPath:nsource toPath:ndest handler:nil];
|
||||
|
||||
[pool release];
|
||||
bool ret = [manager copyItemAtPath:nsource toPath:ndest error:nil];
|
||||
// n.b.: The "success" semantics don't guarantee a copy actually took place, so we'll verify
|
||||
// because this is surprising behavior for a method called copy.
|
||||
if( ![manager fileExistsAtPath:ndest] )
|
||||
{
|
||||
Con::warnf("The filemanager returned success, but the file was not copied. Something strange is happening");
|
||||
ret = false;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -117,6 +125,7 @@ bool dFileRename(const char *source, const char *dest)
|
|||
if(source == NULL || dest == NULL)
|
||||
return false;
|
||||
|
||||
@autoreleasepool {
|
||||
NSFileManager *manager = [NSFileManager defaultManager];
|
||||
|
||||
NSString *nsource = [manager stringWithFileSystemRepresentation:source length:dStrlen(source)];
|
||||
|
|
@ -133,9 +142,18 @@ bool dFileRename(const char *source, const char *dest)
|
|||
Con::warnf("dFileRename: Deleting files at path: %s", dest);
|
||||
}
|
||||
|
||||
bool ret = [manager movePath:nsource toPath:ndest handler:nil];
|
||||
bool ret = [manager moveItemAtPath:nsource toPath:ndest error:nil];
|
||||
// n.b.: The "success" semantics don't guarantee a move actually took place, so we'll verify
|
||||
// because this is surprising behavior for a method called rename.
|
||||
|
||||
if( ![manager fileExistsAtPath:ndest] )
|
||||
{
|
||||
Con::warnf("The filemanager returned success, but the file was not moved. Something strange is happening");
|
||||
ret = false;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Reference in a new issue