view dwt/internal/cocoa/NSTimer.d @ 37:642f460a0908

Fixed a lot of compile errors, a "hello world" app compiles now
author Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
date Fri, 10 Oct 2008 12:29:48 +0200
parents f565d3a95c0a
children d8635bb48c7c
line wrap: on
line source

/*******************************************************************************
 * Copyright (c) 2007 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *     
 * Port to the D programming language:
 *     Jacob Carlborg <jacob.carlborg@gmail.com>
 *******************************************************************************/
module dwt.internal.cocoa.NSTimer;

import dwt.internal.cocoa.id;
import dwt.internal.cocoa.NSDate;
import dwt.internal.cocoa.NSInvocation;
import dwt.internal.cocoa.NSObject;
import dwt.internal.cocoa.OS;
import objc = dwt.internal.objc.runtime;

import dwt.dwthelper.utils;

public class NSTimer : NSObject
{

    public this ()
    {
        super();
    }

    public this (objc.id id)
    {
        super(id);
    }

    public void fire ()
    {
        OS.objc_msgSend(this.id_, OS.sel_fire);
    }

    public NSDate fireDate ()
    {
        objc.id result = OS.objc_msgSend(this.id_, OS.sel_fireDate);
        return result !is null ? new NSDate(result) : null;
    }

    public id initWithFireDate (NSDate date, NSTimeInterval ti, id t, objc.SEL s, id ui, bool rep)
    {
        objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithFireDate_1interval_1target_1selector_1userInfo_1repeats_1,
                date !is null ? date.id_ : null, ti, t !is null ? t.id_ : null, s, ui !is null ? ui.id_ : null, rep);
        return result !is null ? new id(result) : null;
    }

    public void invalidate ()
    {
        OS.objc_msgSend(this.id_, OS.sel_invalidate);
    }

    public bool isValid ()
    {
        return OS.objc_msgSend(this.id_, OS.sel_isValid) !is null;
    }

    public static NSTimer static_scheduledTimerWithTimeInterval_invocation_repeats_ (NSTimeInterval ti, NSInvocation invocation, bool yesOrNo)
    {
        objc.id result = OS.objc_msgSend(OS.class_NSTimer, OS.sel_scheduledTimerWithTimeInterval_1invocation_1repeats_1, ti,
                invocation !is null ? invocation.id_ : null, yesOrNo);
        return result !is null ? new NSTimer(result) : null;
    }

    public static NSTimer static_scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_ (NSTimeInterval ti, id aTarget, String aSelector,
            objc.id userInfo, bool yesOrNo)
    {
        objc.id result = OS.objc_msgSend(OS.class_NSTimer, OS.sel_scheduledTimerWithTimeInterval_1target_1selector_1userInfo_1repeats_1, ti,
                aTarget !is null ? aTarget.id_ : null, aSelector.ptr, userInfo, yesOrNo);
        return result !is null ? new NSTimer(result) : null;
    }

    public void setFireDate (NSDate date)
    {
        OS.objc_msgSend(this.id_, OS.sel_setFireDate_1, date !is null ? date.id_ : null);
    }

    public NSTimeInterval timeInterval ()
    {
        return cast(NSTimeInterval) OS.objc_msgSend_fpret(this.id_, OS.sel_timeInterval);
    }

    public static NSTimer static_timerWithTimeInterval_invocation_repeats_ (NSTimeInterval ti, NSInvocation invocation, bool yesOrNo)
    {
        objc.id result = OS.objc_msgSend(OS.class_NSTimer, OS.sel_timerWithTimeInterval_1invocation_1repeats_1, ti,
                invocation !is null ? invocation.id_ : null, yesOrNo);
        return result !is null ? new NSTimer(result) : null;
    }

    public static NSTimer static_timerWithTimeInterval_target_selector_userInfo_repeats_ (NSTimeInterval ti, id aTarget, String aSelector, id userInfo,
            bool yesOrNo)
    {
        objc.id result = OS.objc_msgSend(OS.class_NSTimer, OS.sel_timerWithTimeInterval_1target_1selector_1userInfo_1repeats_1, ti,
                aTarget !is null ? aTarget.id_ : null, aSelector.ptr, userInfo !is null ? userInfo.id_ : null, yesOrNo);
        return result !is null ? new NSTimer(result) : null;
    }

    public objc.id userInfo ()
    {
        return OS.objc_msgSend(this.id_, OS.sel_userInfo);
    }

}