From: Jay Freeman (saurik) Date: Sat, 16 Feb 2013 11:38:54 +0000 (+0000) Subject: Copy the _H template from an older substrate.h. X-Git-Tag: v0.9.4007~7 X-Git-Url: https://git.saurik.com/cydget.git/commitdiff_plain/0c1e3ef082163abe6f56c549221eef7c01cf219f?ds=inline Copy the _H template from an older substrate.h. --- diff --git a/Handle.hpp b/Handle.hpp new file mode 100644 index 0000000..fe7ed0f --- /dev/null +++ b/Handle.hpp @@ -0,0 +1,90 @@ +/* Cydget - open-source AwayView plugin multiplexer + * Copyright (C) 2009-2012 Jay Freeman (saurik) +*/ + +/* + * Redistribution and use in source and binary + * forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the + * above copyright notice, this list of conditions + * and the following disclaimer. + * 2. Redistributions in binary form must reproduce the + * above copyright notice, this list of conditions + * and the following disclaimer in the documentation + * and/or other materials provided with the + * distribution. + * 3. The name of the author may not be used to endorse + * or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, + * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef HANDLE_HPP +#define HANDLE_HPP + +template +class _H { + typedef _H This_; + + private: + Type_ *value_; + + _finline void Retain_() { + if (value_ != nil) + CFRetain((CFTypeRef) value_); + } + + _finline void Clear_() { + if (value_ != nil) + CFRelease((CFTypeRef) value_); + } + + public: + _finline _H(const This_ &rhs) : + value_(rhs.value_ == nil ? nil : (Type_ *) CFRetain((CFTypeRef) rhs.value_)) + { + } + + _finline _H(Type_ *value = NULL, bool mended = false) : + value_(value) + { + if (!mended) + Retain_(); + } + + _finline ~_H() { + Clear_(); + } + + _finline operator Type_ *() const { + return value_; + } + + _finline This_ &operator =(Type_ *value) { + if (value_ != value) { + Type_ *old(value_); + value_ = value; + Retain_(); + if (old != nil) + CFRelease((CFTypeRef) old); + } return *this; + } +}; + +#endif//HANDLE_HPP diff --git a/Tweak.mm b/Tweak.mm index e957efe..9c3470b 100644 --- a/Tweak.mm +++ b/Tweak.mm @@ -46,6 +46,8 @@ #import #import +#include "Handle.hpp" + MSClassHook(SpringBoard) MSClassHook(SBAwayController)