All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.bugvm.apple.corefoundation.CFNumber Maven / Gradle / Ivy

There is a newer version: 1.2.9
Show newest version
/*
 * Copyright (C) 2013-2015 RoboVM AB
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.bugvm.apple.corefoundation;

/**/
import java.io.*;
import java.nio.*;
import java.util.*;
import com.bugvm.objc.*;
import com.bugvm.objc.annotation.*;
import com.bugvm.objc.block.*;
import com.bugvm.rt.*;
import com.bugvm.rt.annotation.*;
import com.bugvm.rt.bro.*;
import com.bugvm.rt.bro.annotation.*;
import com.bugvm.rt.bro.ptr.*;
import com.bugvm.apple.foundation.*;
import com.bugvm.apple.dispatch.*;
import com.bugvm.apple.coreservices.*;
import com.bugvm.apple.coremedia.*;
import com.bugvm.apple.uikit.*;
import com.bugvm.apple.coretext.*;
/**/

/**/
/**/
/**/@Library("CoreFoundation")/**/
/**/public/**/ class /**/CFNumber/**/ 
    extends /**/CFPropertyList/**/ 
    /**//**/ {

    /**/public static class CFNumberPtr extends Ptr {}/**/
    /**/static { Bro.bind(CFNumber.class); }/**/
    /**//**/
    /**/
    protected CFNumber() {}
    /**/
    /**//**/
    /**//**/
    public byte byteValue() {
        VoidPtr ptr = new VoidPtr();
        getValue(CFNumberType.SInt8Type, ptr);
        return ptr.as(BytePtr.class).get();
    }
    public short shortValue() {
        VoidPtr ptr = new VoidPtr();
        getValue(CFNumberType.SInt16Type, ptr);
        return ptr.as(ShortPtr.class).get();
    }
    public char charValue() {
        VoidPtr ptr = new VoidPtr();
        getValue(CFNumberType.SInt16Type, ptr);
        return ptr.as(CharPtr.class).get();
    }
    public int intValue() {
        VoidPtr ptr = new VoidPtr();
        getValue(CFNumberType.SInt32Type, ptr);
        return ptr.as(IntPtr.class).get();
    }
    public long longValue() {
        VoidPtr ptr = new VoidPtr();
        getValue(CFNumberType.SInt8Type, ptr);
        return ptr.as(LongPtr.class).get();
    }
    public float floatValue() {
        VoidPtr ptr = new VoidPtr();
        getValue(CFNumberType.Float32Type, ptr);
        return ptr.as(FloatPtr.class).get();
    }
    public double doubleValue() {
        VoidPtr ptr = new VoidPtr();
        getValue(CFNumberType.Float64Type, ptr);
        return ptr.as(DoublePtr.class).get();
    }
    public boolean booleanValue() {
        int b = intValue();
        if (b == 0) return false;
        return true;
    }
    public static CFNumber valueOf(byte value) {
        return create(null, CFNumberType.SInt8Type, new BytePtr(value).as(VoidPtr.class));
    }
    public static CFNumber valueOf(short value) {
        return create(null, CFNumberType.SInt16Type, new ShortPtr(value).as(VoidPtr.class));
    }
    public static CFNumber valueOf(char value) {
        return create(null, CFNumberType.SInt16Type, new CharPtr(value).as(VoidPtr.class));
    }
    public static CFNumber valueOf(int value) {
        return create(null, CFNumberType.SInt32Type, new IntPtr(value).as(VoidPtr.class));
    }
    public static CFNumber valueOf(long value) {
        return create(null, CFNumberType.SInt64Type, new LongPtr(value).as(VoidPtr.class));
    }
    public static CFNumber valueOf(float value) {
        return create(null, CFNumberType.Float32Type, new FloatPtr(value).as(VoidPtr.class));
    }
    public static CFNumber valueOf(double value) {
        return create(null, CFNumberType.Float64Type, new DoublePtr(value).as(VoidPtr.class));
    }
    public static CFNumber valueOf(boolean value) {
        return create(null, CFNumberType.SInt32Type, new IntPtr(value ? 1 : 0).as(VoidPtr.class));
    }
    public static CFNumber valueOf(Number value) {
        if (value instanceof Byte) {
            return valueOf((byte)value);
        }
        if (value instanceof Short) {
            return valueOf((short)value);
        }
        if (value instanceof Integer) {
            return valueOf((int)value);
        }
        if (value instanceof Long) {
            return valueOf((long)value);
        }
        if (value instanceof Float) {
            return valueOf((float)value);
        }
        if (value instanceof Double) {
            return valueOf((double)value);
        }
        throw new IllegalArgumentException("value is not a supported number type: " + value.getClass());
    }
    
    public CFComparisonResult compareTo(CFNumber otherNumber) {
        return compareTo(otherNumber, null);
    }
    /**/
    @GlobalValue(symbol="kCFNumberPositiveInfinity", optional=true)
    public static native CFNumber getPositiveInfinity();
    @GlobalValue(symbol="kCFNumberNegativeInfinity", optional=true)
    public static native CFNumber getNegativeInfinity();
    @GlobalValue(symbol="kCFNumberNaN", optional=true)
    public static native CFNumber getNaN();
    
    @Bridge(symbol="CFNumberGetTypeID", optional=true)
    public static native @MachineSizedUInt long getClassTypeID();
    @Bridge(symbol="CFNumberCreate", optional=true)
    private static native @com.bugvm.rt.bro.annotation.Marshaler(CFType.NoRetainMarshaler.class) CFNumber create(CFAllocator allocator, CFNumberType theType, VoidPtr valuePtr);
    @Bridge(symbol="CFNumberGetType", optional=true)
    public native CFNumberType getType();
    @Bridge(symbol="CFNumberGetByteSize", optional=true)
    public native @MachineSizedSInt long getByteSize();
    @Bridge(symbol="CFNumberIsFloatType", optional=true)
    public native boolean isFloatType();
    @Bridge(symbol="CFNumberGetValue", optional=true)
    private native boolean getValue(CFNumberType theType, VoidPtr valuePtr);
    @Bridge(symbol="CFNumberCompare", optional=true)
    private native CFComparisonResult compareTo(CFNumber otherNumber, VoidPtr context);
    /**/
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy