Skip to content

Commit

Permalink
Move CFRunLoopObserver to CPRunLoop.j as a global function
Browse files Browse the repository at this point in the history
  • Loading branch information
cacaodev committed Mar 2, 2017
1 parent 3edddb8 commit 14ebd58
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 48 deletions.
48 changes: 0 additions & 48 deletions AppKit/CoreAnimation/CPAnimationContext.j
Expand Up @@ -586,54 +586,6 @@ var _animationFlushingObserverCallback = function()
}
};

CFRunLoopObserver = function(activities, repeats, order, callout, context)
{
this.activities = activities;
this.repeats = repeats;
this.order = order;
this.callout = callout;
this.context = context;

this.isvalid = true;
};

CFRunLoopObserverCreate = function(activities, repeats, order, callout, context)
{
return new CFRunLoopObserver(activities, repeats, order, callout, context);
};

CFRunLoopAddObserver = function(runloop, observer, mode)
{
var observers = runloop._observers;

if (!observers)
observers = (runloop._observers = []);

if (observers.indexOf(observer) == -1)
observers.push(observer);
};

CFRunLoopObserverInvalidate = function(runloop, observer, mode)
{
CFRunLoopRemoveObserver(runloop, observer, mode);
};

CFRunLoopRemoveObserver = function(runloop, observer, mode)
{
var observers = runloop._observers;
if (observers)
{
var idx = observers.indexOf(observer);
if (idx !== -1)
{
observers.splice(idx, 1);

if (observers.length == 0)
runloop._observers = nil;
}
}
};

var FrameUpdater = function(anIdentifier)
{
this._identifier = anIdentifier;
Expand Down
48 changes: 48 additions & 0 deletions Foundation/CPRunLoop.j
Expand Up @@ -494,3 +494,51 @@ var CPRunLoopLastNativeRunLoop = 0;
}

@end

function CFRunLoopObserver(activities, repeats, order, callout, context)
{
this.activities = activities;
this.repeats = repeats;
this.order = order;
this.callout = callout;
this.context = context;

this.isvalid = true;
};

function CFRunLoopObserverCreate(activities, repeats, order, callout, context)
{
return new CFRunLoopObserver(activities, repeats, order, callout, context);
};

function CFRunLoopAddObserver(runloop, observer, mode)
{
var observers = runloop._observers;

if (!observers)
observers = (runloop._observers = []);

if (observers.indexOf(observer) == -1)
observers.push(observer);
};

function CFRunLoopObserverInvalidate(runloop, observer, mode)
{
CFRunLoopRemoveObserver(runloop, observer, mode);
};

function CFRunLoopRemoveObserver(runloop, observer, mode)
{
var observers = runloop._observers;
if (observers)
{
var idx = observers.indexOf(observer);
if (idx !== -1)
{
observers.splice(idx, 1);

if (observers.length == 0)
runloop._observers = nil;
}
}
};

0 comments on commit 14ebd58

Please sign in to comment.