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

Code cleanup and warning fixes #58

Merged
merged 2 commits into from Feb 21, 2015
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Prev

Removed dummy parametr in `type_id` method.

Closes #17
Now call like:
`let id = <CFBoolean as TCFType<_>>::type_id();`

[breaking-change]
  • Loading branch information
zummenix committed Feb 18, 2015
commit 36b7b6104d649f4a3fd4483014073c50e8d4878a
@@ -104,7 +104,7 @@ impl TCFType<CFArrayRef> for CFArray {
}

#[inline]
fn type_id(_: Option<CFArray>) -> CFTypeID {
fn type_id() -> CFTypeID {
unsafe {
CFArrayGetTypeID()
}
@@ -106,10 +106,7 @@ pub trait TCFType<ConcreteTypeRef> {
unsafe fn wrap_under_create_rule(obj: ConcreteTypeRef) -> Self;

/// Returns the type ID for this class.
///
/// FIXME(pcwalton): The dummy parameter is there to work around the current inexpressivity of
/// the Rust language.
fn type_id(dummy: Option<Self>) -> CFTypeID;
fn type_id() -> CFTypeID;

/// Returns the object as a wrapped `CFType`. The reference count is incremented by one.
#[inline]
@@ -153,8 +150,7 @@ pub trait TCFType<ConcreteTypeRef> {
/// Returns true if this value is an instance of another type.
#[inline]
fn instance_of<OtherConcreteTypeRef,OtherCFType:TCFType<OtherConcreteTypeRef>>(&self) -> bool {
let dummy: Option<OtherCFType> = None;
self.type_of() == TCFType::type_id(dummy)
self.type_of() == <OtherCFType as TCFType<_>>::type_id()
}
}

@@ -183,7 +179,7 @@ impl TCFType<CFTypeRef> for CFType {
}

#[inline]
fn type_id(_: Option<CFType>) -> CFTypeID {
fn type_id() -> CFTypeID {
// FIXME(pcwalton): Is this right?
0
}
@@ -60,7 +60,7 @@ impl TCFType<CFBooleanRef> for CFBoolean {
}

#[inline]
fn type_id(_: Option<CFBoolean>) -> CFTypeID {
fn type_id() -> CFTypeID {
unsafe {
CFBooleanGetTypeID()
}
@@ -61,7 +61,7 @@ impl TCFType<CFBundleRef> for CFBundle {
}

#[inline]
fn type_id(_: Option<CFBundle>) -> CFTypeID {
fn type_id() -> CFTypeID {
unsafe {
CFBundleGetTypeID()
}
@@ -60,7 +60,7 @@ impl TCFType<CFDataRef> for CFData {
}

#[inline]
fn type_id(_: Option<CFData>) -> CFTypeID {
fn type_id() -> CFTypeID {
unsafe {
CFDataGetTypeID()
}
@@ -92,7 +92,7 @@ impl TCFType<CFDictionaryRef> for CFDictionary {
}

#[inline]
fn type_id(_: Option<CFDictionary>) -> CFTypeID {
fn type_id() -> CFTypeID {
unsafe {
CFDictionaryGetTypeID()
}
@@ -85,7 +85,7 @@ impl TCFType<CFNumberRef> for CFNumber {
}

#[inline]
fn type_id(_: Option<CFNumber>) -> CFTypeID {
fn type_id() -> CFTypeID {
unsafe {
CFNumberGetTypeID()
}
@@ -59,7 +59,7 @@ impl TCFType<CFRunLoopRef> for CFRunLoop {
}

#[inline]
fn type_id(_: Option<CFRunLoop>) -> CFTypeID {
fn type_id() -> CFTypeID {
unsafe {
CFRunLoopGetTypeID()
}
@@ -246,7 +246,7 @@ impl TCFType<CFRunLoopTimerRef> for CFRunLoopTimer {
}

#[inline]
fn type_id(_: Option<CFRunLoopTimer>) -> CFTypeID {
fn type_id() -> CFTypeID {
unsafe {
CFRunLoopTimerGetTypeID()
}
@@ -79,7 +79,7 @@ impl TCFType<CFSetRef> for CFSet {
}

#[inline]
fn type_id(_: Option<CFSet>) -> CFTypeID {
fn type_id() -> CFTypeID {
unsafe {
CFSetGetTypeID()
}
@@ -255,7 +255,7 @@ impl TCFType<CFStringRef> for CFString {
}

#[inline]
fn type_id(_: Option<CFString>) -> CFTypeID {
fn type_id() -> CFTypeID {
unsafe {
CFStringGetTypeID()
}
@@ -62,7 +62,7 @@ impl TCFType<CFURLRef> for CFURL {
}

#[inline]
fn type_id(_: Option<CFURL>) -> CFTypeID {
fn type_id() -> CFTypeID {
unsafe {
CFURLGetTypeID()
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.