view dwt/internal/cocoa/NSInvocation.d @ 13:f565d3a95c0a

Ported dwt.internal
author Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
date Fri, 22 Aug 2008 16:46:34 +0200
parents 8b48be5454ce
children
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.NSInvocation;

import dwt.internal.cocoa.id;
import dwt.internal.cocoa.NSInteger;
import dwt.internal.cocoa.NSMethodSignature;
import dwt.internal.cocoa.NSObject;
import dwt.internal.cocoa.OS;
import objc = dwt.internal.objc.runtime;

public class NSInvocation : NSObject
{

    public this ()
    {
        super();
    }

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

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

    public void getArgument (void* argumentLocation, NSInteger idx)
    {
        OS.objc_msgSend(this.id_, OS.sel_getArgument_1atIndex_1, argumentLocation, idx);
    }

    public void getReturnValue (void* retLoc)
    {
        OS.objc_msgSend(this.id_, OS.sel_getReturnValue_1, retLoc);
    }

    public static NSInvocation invocationWithMethodSignature (NSMethodSignature sig)
    {
        objc.id result = OS.objc_msgSend(OS.class_NSInvocation, OS.sel_invocationWithMethodSignature_1, sig !is null ? sig.id_ : null);
        return result !is null ? new NSInvocation(result) : null;
    }

    public void invoke ()
    {
        OS.objc_msgSend(this.id_, OS.sel_invoke);
    }

    public void invokeWithTarget (id target)
    {
        OS.objc_msgSend(this.id_, OS.sel_invokeWithTarget_1, target !is null ? target.id_ : null);
    }

    public NSMethodSignature methodSignature ()
    {
        objc.id result = OS.objc_msgSend(this.id_, OS.sel_methodSignature);
        return result !is null ? new NSMethodSignature(result) : null;
    }

    public void retainArguments ()
    {
        OS.objc_msgSend(this.id_, OS.sel_retainArguments);
    }

    public objc.SEL selector ()
    {
        return cast(objc.SEL) OS.objc_msgSend(this.id_, OS.sel_selector);
    }

    public void setArgument (void* argumentLocation, NSInteger idx)
    {
        OS.objc_msgSend(this.id_, OS.sel_setArgument_1atIndex_1, argumentLocation, idx);
    }

    public void setReturnValue (void* retLoc)
    {
        OS.objc_msgSend(this.id_, OS.sel_setReturnValue_1, retLoc);
    }

    public void setSelector (objc.SEL selector)
    {
        OS.objc_msgSend(this.id_, OS.sel_setSelector_1, selector);
    }

    public void setTarget (id target)
    {
        OS.objc_msgSend(this.id_, OS.sel_setTarget_1, target !is null ? target.id_ : null);
    }

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

}