Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split a -sys crate out #68

Merged
merged 19 commits into from Oct 15, 2015

Move dictionary and number to sys crate

  • Loading branch information
sfackler committed Sep 6, 2015
commit e53893b80998b03ef0ee5110798f83ed8779c537
@@ -0,0 +1,57 @@
use libc::{c_void};

use base::{CFAllocatorRef, CFIndex, CFTypeID, Boolean};

pub type CFDictionaryApplierFunction = *const u8;
pub type CFDictionaryCopyDescriptionCallBack = *const u8;
pub type CFDictionaryEqualCallBack = *const u8;
pub type CFDictionaryHashCallBack = *const u8;
pub type CFDictionaryReleaseCallBack = *const u8;
pub type CFDictionaryRetainCallBack = *const u8;

#[allow(dead_code)]
#[repr(C)]
#[derive(Clone, Copy)]
pub struct CFDictionaryKeyCallBacks {
pub version: CFIndex,
pub retain: CFDictionaryRetainCallBack,
pub release: CFDictionaryReleaseCallBack,
pub copyDescription: CFDictionaryCopyDescriptionCallBack,
pub equal: CFDictionaryEqualCallBack,
pub hash: CFDictionaryHashCallBack
}

#[allow(dead_code)]
#[repr(C)]
#[derive(Clone, Copy)]
pub struct CFDictionaryValueCallBacks {
pub version: CFIndex,
pub retain: CFDictionaryRetainCallBack,
pub release: CFDictionaryReleaseCallBack,
pub copyDescription: CFDictionaryCopyDescriptionCallBack,
pub equal: CFDictionaryEqualCallBack
}

#[repr(C)]
struct __CFDictionary;

pub type CFDictionaryRef = *const __CFDictionary;

extern {
/*
* CFDictionary.h
*/

pub static kCFTypeDictionaryKeyCallBacks: CFDictionaryKeyCallBacks;
pub static kCFTypeDictionaryValueCallBacks: CFDictionaryValueCallBacks;

pub fn CFDictionaryContainsKey(theDict: CFDictionaryRef, key: *const c_void) -> Boolean;
pub fn CFDictionaryCreate(allocator: CFAllocatorRef, keys: *const *const c_void, values: *const *const c_void,
numValues: CFIndex, keyCallBacks: *const CFDictionaryKeyCallBacks,
valueCallBacks: *const CFDictionaryValueCallBacks)
-> CFDictionaryRef;
pub fn CFDictionaryGetCount(theDict: CFDictionaryRef) -> CFIndex;
pub fn CFDictionaryGetTypeID() -> CFTypeID;
pub fn CFDictionaryGetValueIfPresent(theDict: CFDictionaryRef, key: *const c_void, value: *mut *const c_void)
-> Boolean;
}
@@ -7,5 +7,6 @@ pub mod base;
pub mod bundle;
pub mod data;
pub mod date;
pub mod dictionary;
pub mod number;
pub mod string;
@@ -1,12 +1,47 @@
use libc::c_void;

use base::CFTypeID;
use base::{CFAllocatorRef, CFTypeID};

pub type CFBooleanRef = *const c_void;

pub type CFNumberType = u32;

// members of enum CFNumberType
// static kCFNumberSInt8Type: CFNumberType = 1;
// static kCFNumberSInt16Type: CFNumberType = 2;
pub static kCFNumberSInt32Type: CFNumberType = 3;
pub static kCFNumberSInt64Type: CFNumberType = 4;
// static kCFNumberFloat32Type: CFNumberType = 5;
pub static kCFNumberFloat64Type: CFNumberType = 6;
// static kCFNumberCharType: CFNumberType = 7;
// static kCFNumberShortType: CFNumberType = 8;
// static kCFNumberIntType: CFNumberType = 9;
// static kCFNumberLongType: CFNumberType = 10;
// static kCFNumberLongLongType: CFNumberType = 11;
// static kCFNumberFloatType: CFNumberType = 12;
// static kCFNumberDoubleType: CFNumberType = 13;
// static kCFNumberCFIndexType: CFNumberType = 14;
// static kCFNumberNSIntegerType: CFNumberType = 15;
// static kCFNumberCGFloatType: CFNumberType = 16;
// static kCFNumberMaxType: CFNumberType = 16;

#[repr(C)]
struct __CFNumber;

pub type CFNumberRef = *const __CFNumber;

extern {
/*
* CFNumber.h
*/
pub static kCFBooleanTrue: CFBooleanRef;
pub static kCFBooleanFalse: CFBooleanRef;

pub fn CFBooleanGetTypeID() -> CFTypeID;
pub fn CFNumberCreate(allocator: CFAllocatorRef, theType: CFNumberType, valuePtr: *const c_void)
-> CFNumberRef;
//fn CFNumberGetByteSize
pub fn CFNumberGetValue(number: CFNumberRef, theType: CFNumberType, valuePtr: *mut c_void) -> bool;
//fn CFNumberCompare
pub fn CFNumberGetTypeID() -> CFTypeID;
}
@@ -9,49 +9,15 @@

//! Dictionaries of key-value pairs.

use core_foundation_sys::base::{Boolean, CFAllocatorRef, CFIndex, CFRelease};
use core_foundation_sys::base::{CFTypeID, CFTypeRef, kCFAllocatorDefault};
use core_foundation_sys::base::CFRelease;
use core_foundation_sys::base::{CFTypeRef, kCFAllocatorDefault};
use core_foundation_sys::dictionary::*;
use libc::c_void;
use std::mem;
use std::ptr;

use base::{CFType, CFIndexConvertible, TCFType};

pub type CFDictionaryApplierFunction = *const u8;
pub type CFDictionaryCopyDescriptionCallBack = *const u8;
pub type CFDictionaryEqualCallBack = *const u8;
pub type CFDictionaryHashCallBack = *const u8;
pub type CFDictionaryReleaseCallBack = *const u8;
pub type CFDictionaryRetainCallBack = *const u8;

#[allow(dead_code)]
#[repr(C)]
#[derive(Clone, Copy)]
pub struct CFDictionaryKeyCallBacks {
version: CFIndex,
retain: CFDictionaryRetainCallBack,
release: CFDictionaryReleaseCallBack,
copyDescription: CFDictionaryCopyDescriptionCallBack,
equal: CFDictionaryEqualCallBack,
hash: CFDictionaryHashCallBack
}

#[allow(dead_code)]
#[repr(C)]
#[derive(Clone, Copy)]
pub struct CFDictionaryValueCallBacks {
version: CFIndex,
retain: CFDictionaryRetainCallBack,
release: CFDictionaryReleaseCallBack,
copyDescription: CFDictionaryCopyDescriptionCallBack,
equal: CFDictionaryEqualCallBack
}

#[repr(C)]
struct __CFDictionary;

pub type CFDictionaryRef = *const __CFDictionary;

/// An immutable dictionary of key-value pairs.
pub struct CFDictionary(CFDictionaryRef);

@@ -131,23 +97,3 @@ impl CFDictionary {
TCFType::wrap_under_get_rule(value)
}
}

#[link(name = "CoreFoundation", kind = "framework")]
extern {
/*
* CFDictionary.h
*/

static kCFTypeDictionaryKeyCallBacks: CFDictionaryKeyCallBacks;
static kCFTypeDictionaryValueCallBacks: CFDictionaryValueCallBacks;

fn CFDictionaryContainsKey(theDict: CFDictionaryRef, key: *const c_void) -> Boolean;
fn CFDictionaryCreate(allocator: CFAllocatorRef, keys: *const *const c_void, values: *const *const c_void,
numValues: CFIndex, keyCallBacks: *const CFDictionaryKeyCallBacks,
valueCallBacks: *const CFDictionaryValueCallBacks)
-> CFDictionaryRef;
fn CFDictionaryGetCount(theDict: CFDictionaryRef) -> CFIndex;
fn CFDictionaryGetTypeID() -> CFTypeID;
fn CFDictionaryGetValueIfPresent(theDict: CFDictionaryRef, key: *const c_void, value: *mut *const c_void)
-> Boolean;
}
@@ -11,39 +11,12 @@

#![allow(non_upper_case_globals)]

use core_foundation_sys::base::{CFAllocatorRef, CFRelease, CFTypeID};
use core_foundation_sys::base::{kCFAllocatorDefault};
use libc::c_void;
use core_foundation_sys::base::{CFRelease, kCFAllocatorDefault};
use core_foundation_sys::number::*;
use std::mem;

use base::{TCFType};

pub type CFNumberType = u32;

// members of enum CFNumberType
// static kCFNumberSInt8Type: CFNumberType = 1;
// static kCFNumberSInt16Type: CFNumberType = 2;
static kCFNumberSInt32Type: CFNumberType = 3;
static kCFNumberSInt64Type: CFNumberType = 4;
// static kCFNumberFloat32Type: CFNumberType = 5;
static kCFNumberFloat64Type: CFNumberType = 6;
// static kCFNumberCharType: CFNumberType = 7;
// static kCFNumberShortType: CFNumberType = 8;
// static kCFNumberIntType: CFNumberType = 9;
// static kCFNumberLongType: CFNumberType = 10;
// static kCFNumberLongLongType: CFNumberType = 11;
// static kCFNumberFloatType: CFNumberType = 12;
// static kCFNumberDoubleType: CFNumberType = 13;
// static kCFNumberCFIndexType: CFNumberType = 14;
// static kCFNumberNSIntegerType: CFNumberType = 15;
// static kCFNumberCGFloatType: CFNumberType = 16;
// static kCFNumberMaxType: CFNumberType = 16;

#[repr(C)]
struct __CFNumber;

pub type CFNumberRef = *const __CFNumber;

/// An immutable numeric value.
pub struct CFNumber(CFNumberRef);

@@ -112,18 +85,3 @@ impl CFNumber {
pub fn number(value: i64) -> CFNumber {
CFNumber::from_i64(value)
}

#[link(name = "CoreFoundation", kind = "framework")]
extern {
/*
* CFNumber.h
*/


fn CFNumberCreate(allocator: CFAllocatorRef, theType: CFNumberType, valuePtr: *const c_void)
-> CFNumberRef;
//fn CFNumberGetByteSize
fn CFNumberGetValue(number: CFNumberRef, theType: CFNumberType, valuePtr: *mut c_void) -> bool;
//fn CFNumberCompare
fn CFNumberGetTypeID() -> CFTypeID;
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.