mirror of
https://github.com/copyrighttxt/watrbx-game-engine.git
synced 2026-09-05 05:07:48 +00:00
59 lines
1.4 KiB
Plaintext
59 lines
1.4 KiB
Plaintext
//
|
|
// Roblox.m
|
|
// RobloxMobile
|
|
//
|
|
// Created by Ben Tkacheff on 1/30/13.
|
|
// Copyright (c) 2013 ROBLOX. All rights reserved.
|
|
//
|
|
|
|
#import "MarshallerInterface.h"
|
|
#include "FunctionMarshaller.h"
|
|
#include "Roblox.h"
|
|
|
|
|
|
@implementation FunctionMarshaller
|
|
|
|
@synthesize pClosure;
|
|
|
|
-(void) marshallFunction
|
|
{
|
|
RBX::FunctionMarshaller::handleAppEvent(pClosure);
|
|
}
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
static NSString* kAppEventMode = @"RobloxAppEvent";
|
|
static NSArray* kAppEventModeList = [NSArray arrayWithObjects:(NSString*)kCFRunLoopDefaultMode, kAppEventMode, nil];
|
|
|
|
void Roblox::sendAppEvent(void *pClosure)
|
|
{
|
|
RBX::CEvent *waitEvent = ((RBX::FunctionMarshaller::Closure *) pClosure)->waitEvent;
|
|
BOOL waitFlag = (waitEvent == NULL);
|
|
|
|
FunctionMarshaller* controller = [[FunctionMarshaller alloc] init];
|
|
controller->pClosure = pClosure;
|
|
|
|
[controller performSelectorOnMainThread:@selector(marshallFunction) withObject:nil waitUntilDone:waitFlag modes:kAppEventModeList];
|
|
|
|
if (waitEvent)
|
|
{
|
|
waitEvent->Wait();
|
|
}
|
|
}
|
|
|
|
void Roblox::postAppEvent(void *pClosure)
|
|
{
|
|
FunctionMarshaller* controller = [[FunctionMarshaller alloc] init];
|
|
controller->pClosure = pClosure;
|
|
|
|
[controller performSelectorOnMainThread:@selector(marshallFunction) withObject:nil waitUntilDone:NO modes:kAppEventModeList];
|
|
}
|
|
|
|
void Roblox::processAppEvents()
|
|
{
|
|
while (CFRunLoopRunInMode((CFStringRef)kAppEventMode, 0, true) == kCFRunLoopRunHandledSource)
|
|
;
|
|
} |