view dwt/internal/cocoa/NSDecimalNumber.d @ 0:380af2bdd8e5

Upload of whole dwt tree
author Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
date Sat, 09 Aug 2008 17:00:02 +0200
parents
children 8b48be5454ce
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.NSDecimalNumber;

import dwt.internal.cocoa.id;
import dwt.internal.cocoa.NSComparisonResult;
import dwt.internal.cocoa.NSDecimal;
import dwt.internal.cocoa.NSInteger;
import dwt.internal.cocoa.NSNumber;
import dwt.internal.cocoa.NSString;
import dwt.internal.cocoa.OS;
import objc = dwt.internal.objc.runtime;

public class NSDecimalNumber : NSNumber
{

    public this ()
    {
        super();
    }

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

    public NSComparisonResult compare (NSNumber decimalNumber)
    {
        return cast(NSComparisonResult) OS.objc_msgSend(this.id, OS.sel_compare_1, decimalNumber !is null ? decimalNumber.id : null);
    }

    public NSDecimalNumber decimalNumberByAdding_ (NSDecimalNumber decimalNumber)
    {
        objc.id result = OS.objc_msgSend(this.id, OS.sel_decimalNumberByAdding_1, decimalNumber !is null ? decimalNumber.id : null);
        return result is this.id ? this : (result !is null ? new NSDecimalNumber(result) : null);
    }

    public NSDecimalNumber decimalNumberByAdding_withBehavior_ (NSDecimalNumber decimalNumber, id behavior)
    {
        objc.id result = OS.objc_msgSend(this.id, OS.sel_decimalNumberByAdding_1withBehavior_1, decimalNumber !is null ? decimalNumber.id : null,
                behavior !is null ? behavior.id : null);
        return result is this.id ? this : (result !is null ? new NSDecimalNumber(result) : null);
    }

    public NSDecimalNumber decimalNumberByDividingBy_ (NSDecimalNumber decimalNumber)
    {
        objc.id result = OS.objc_msgSend(this.id, OS.sel_decimalNumberByDividingBy_1, decimalNumber !is null ? decimalNumber.id : null);
        return result is this.id ? this : (result !is null ? new NSDecimalNumber(result) : null);
    }

    public NSDecimalNumber decimalNumberByDividingBy_withBehavior_ (NSDecimalNumber decimalNumber, id behavior)
    {
        objc.id result = OS.objc_msgSend(this.id, OS.sel_decimalNumberByDividingBy_1withBehavior_1, decimalNumber !is null ? decimalNumber.id : null,
                behavior !is null ? behavior.id : null);
        return result is this.id ? this : (result !is null ? new NSDecimalNumber(result) : null);
    }

    public NSDecimalNumber decimalNumberByMultiplyingBy_ (NSDecimalNumber decimalNumber)
    {
        objc.id result = OS.objc_msgSend(this.id, OS.sel_decimalNumberByMultiplyingBy_1, decimalNumber !is null ? decimalNumber.id : null);
        return result is this.id ? this : (result !is null ? new NSDecimalNumber(result) : null);
    }

    public NSDecimalNumber decimalNumberByMultiplyingBy_withBehavior_ (NSDecimalNumber decimalNumber, id behavior)
    {
        objc.id result = OS.objc_msgSend(this.id, OS.sel_decimalNumberByMultiplyingBy_1withBehavior_1,
                decimalNumber !is null ? decimalNumber.id : null, behavior !is null ? behavior.id : null);
        return result is this.id ? this : (result !is null ? new NSDecimalNumber(result) : null);
    }

    public NSDecimalNumber decimalNumberByMultiplyingByPowerOf10_ (short power)
    {
        objc.id result = OS.objc_msgSend(this.id, OS.sel_decimalNumberByMultiplyingByPowerOf10_1, power);
        return result is this.id ? this : (result !is null ? new NSDecimalNumber(result) : null);
    }

    public NSDecimalNumber decimalNumberByMultiplyingByPowerOf10_withBehavior_ (short power, id behavior)
    {
        objc.id result = OS.objc_msgSend(this.id, OS.sel_decimalNumberByMultiplyingByPowerOf10_1withBehavior_1, power,
                behavior !is null ? behavior.id : null);
        return result is this.id ? this : (result !is null ? new NSDecimalNumber(result) : null);
    }

    public NSDecimalNumber decimalNumberByRaisingToPower_ (NSUInteger power)
    {
        objc.id result = OS.objc_msgSend(this.id, OS.sel_decimalNumberByRaisingToPower_1, power);
        return result is this.id ? this : (result !is null ? new NSDecimalNumber(result) : null);
    }

    public NSDecimalNumber decimalNumberByRaisingToPower_withBehavior_ (uint power, id behavior)
    {
        objc.id
                result = OS.objc_msgSend(this.id, OS.sel_decimalNumberByRaisingToPower_1withBehavior_1, power, behavior !is null ? behavior.id : null);
        return result is this.id ? this : (result !is null ? new NSDecimalNumber(result) : null);
    }

    public NSDecimalNumber decimalNumberByRoundingAccordingToBehavior (id behavior)
    {
        objc.id result = OS.objc_msgSend(this.id, OS.sel_decimalNumberByRoundingAccordingToBehavior_1, behavior !is null ? behavior.id : null);
        return result is this.id ? this : (result !is null ? new NSDecimalNumber(result) : null);
    }

    public NSDecimalNumber decimalNumberBySubtracting_ (NSDecimalNumber decimalNumber)
    {
        objc.id result = OS.objc_msgSend(this.id, OS.sel_decimalNumberBySubtracting_1, decimalNumber !is null ? decimalNumber.id : null);
        return result is this.id ? this : (result !is null ? new NSDecimalNumber(result) : null);
    }

    public NSDecimalNumber decimalNumberBySubtracting_withBehavior_ (NSDecimalNumber decimalNumber, id behavior)
    {
        objc.id result = OS.objc_msgSend(this.id, OS.sel_decimalNumberBySubtracting_1withBehavior_1,
                decimalNumber !is null ? decimalNumber.id : null, behavior !is null ? behavior.id : null);
        return result is this.id ? this : (result !is null ? new NSDecimalNumber(result) : null);
    }

    public static NSDecimalNumber decimalNumberWithDecimal (NSDecimal dcm)
    {
        objc.id result = OS.objc_msgSend(OS.class_NSDecimalNumber, OS.sel_decimalNumberWithDecimal_1, dcm);
        return result !is null ? new NSDecimalNumber(result) : null;
    }

    public static NSDecimalNumber decimalNumberWithMantissa (long mantissa, short exponent, bool flag)
    {
        objc.id
                result = OS.objc_msgSend(OS.class_NSDecimalNumber, OS.sel_decimalNumberWithMantissa_1exponent_1isNegative_1, mantissa, exponent, flag);
        return result !is null ? new NSDecimalNumber(result) : null;
    }

    public static NSDecimalNumber static_decimalNumberWithString_ (NSString numberValue)
    {
        objc.id result = OS.objc_msgSend(OS.class_NSDecimalNumber, OS.sel_decimalNumberWithString_1, numberValue !is null ? numberValue.id : null);
        return result !is null ? new NSDecimalNumber(result) : null;
    }

    public static NSDecimalNumber static_decimalNumberWithString_locale_ (NSString numberValue, id locale)
    {
        objc.id result = OS.objc_msgSend(OS.class_NSDecimalNumber, OS.sel_decimalNumberWithString_1locale_1,
                numberValue !is null ? numberValue.id : null, locale !is null ? locale.id : null);
        return result !is null ? new NSDecimalNumber(result) : null;
    }

    public NSDecimal decimalValue ()
    {
        NSDecimal result = new NSDecimal();
        OS.objc_msgSend_stret(result, this.id, OS.sel_decimalValue);
        return result;
    }

    public static id defaultBehavior ()
    {
        objc.id result = OS.objc_msgSend(OS.class_NSDecimalNumber, OS.sel_defaultBehavior);
        return result !is null ? new id(result) : null;
    }

    public NSString descriptionWithLocale (id locale)
    {
        objc.id result = OS.objc_msgSend(this.id, OS.sel_descriptionWithLocale_1, locale !is null ? locale.id : null);
        return result !is null ? new NSString(result) : null;
    }

    public double doubleValue ()
    {
        return OS.objc_msgSend_fpret(this.id, OS.sel_doubleValue);
    }

    public id initWithDecimal (NSDecimal dcm)
    {
        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithDecimal_1, dcm);
        return result !is null ? new id(result) : null;
    }

    public id initWithMantissa (ulong mantissa, short exponent, bool flag)
    {
        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithMantissa_1exponent_1isNegative_1, mantissa, exponent, flag);
        return result !is null ? new id(result) : null;
    }

    public id initWithString_ (NSString numberValue)
    {
        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithString_1, numberValue !is null ? numberValue.id : null);
        return result !is null ? new id(result) : null;
    }

    public id initWithString_locale_ (NSString numberValue, id locale)
    {
        objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithString_1locale_1, numberValue !is null ? numberValue.id : null,
                locale !is null ? locale.id : null);
        return result !is null ? new id(result) : null;
    }

    public static NSDecimalNumber maximumDecimalNumber ()
    {
        objc.id result = OS.objc_msgSend(OS.class_NSDecimalNumber, OS.sel_maximumDecimalNumber);
        return result !is null ? new NSDecimalNumber(result) : null;
    }

    public static NSDecimalNumber minimumDecimalNumber ()
    {
        objc.id result = OS.objc_msgSend(OS.class_NSDecimalNumber, OS.sel_minimumDecimalNumber);
        return result !is null ? new NSDecimalNumber(result) : null;
    }

    public static NSDecimalNumber notANumber ()
    {
        objc.id result = OS.objc_msgSend(OS.class_NSDecimalNumber, OS.sel_notANumber);
        return result !is null ? new NSDecimalNumber(result) : null;
    }

    public /*const char* */byte* objCType ()
    {
        return cast(/*const char* */byte*) OS.objc_msgSend(this.id, OS.sel_objCType);
    }

    public static NSDecimalNumber one ()
    {
        objc.id result = OS.objc_msgSend(OS.class_NSDecimalNumber, OS.sel_one);
        return result !is null ? new NSDecimalNumber(result) : null;
    }

    public static void setDefaultBehavior (id behavior)
    {
        OS.objc_msgSend(OS.class_NSDecimalNumber, OS.sel_setDefaultBehavior_1, behavior !is null ? behavior.id : null);
    }

    public static NSDecimalNumber zero ()
    {
        objc.id result = OS.objc_msgSend(OS.class_NSDecimalNumber, OS.sel_zero);
        return result !is null ? new NSDecimalNumber(result) : null;
    }

}