Explorar el Código

Moving scope_guard into its own project

Samuel Jaffe hace 9 años
commit
150a459b8e
Se han modificado 2 ficheros con 266 adiciones y 0 borrados
  1. 35 0
      scope_guard.hpp
  2. 231 0
      scope_guard.xcodeproj/project.pbxproj

+ 35 - 0
scope_guard.hpp

@@ -0,0 +1,35 @@
+//
+//  scope_guard.hpp
+//  memory
+//
+//  Created by Sam Jaffe on 9/24/15.
+//
+//
+
+#pragma once
+
+#include <functional>
+
+struct scope_exit {
+  template <typename F> scope_exit(F f) : _f(f) {}
+  ~scope_exit() noexcept { _f(); }
+  std::function<void()> _f;
+};
+
+#if _cplusplus > 201402L
+template <bool B>
+struct scope_exception {
+  template <typename F> scope_exception(F f) : _f(f), _except(std::uncaught_exceptions()) {}
+  ~scope_exception() noexcept(B) { if (B == (std::uncaught_exceptions() > _except)) _f(); }
+  std::function<void()> _f;
+  int const _except;
+};
+
+using scope_failure = scope_exception<true>;
+using scope_success = scope_exception<false>;
+#endif
+
+#define CONCAT2(A, B) A##B
+#define CONCAT(A, B) CONCAT2(A, B)
+#define scope(t) scope_##t CONCAT(inline_scope_guard_##t##_,__LINE__) = [&]()
+#define scope_guard(t, f) scope_##t CONCAT(scope_guard_##t##_,__LINE__){f};

+ 231 - 0
scope_guard.xcodeproj/project.pbxproj

@@ -0,0 +1,231 @@
+// !$*UTF8*$!
+{
+	archiveVersion = 1;
+	classes = {
+	};
+	objectVersion = 46;
+	objects = {
+
+/* Begin PBXCopyFilesBuildPhase section */
+		CD3DA4071D9B42F4001B53A0 /* CopyFiles */ = {
+			isa = PBXCopyFilesBuildPhase;
+			buildActionMask = 2147483647;
+			dstPath = /usr/share/man/man1/;
+			dstSubfolderSpec = 0;
+			files = (
+			);
+			runOnlyForDeploymentPostprocessing = 1;
+		};
+/* End PBXCopyFilesBuildPhase section */
+
+/* Begin PBXFileReference section */
+		CD3DA4091D9B42F4001B53A0 /* scope_guard */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = scope_guard; sourceTree = BUILT_PRODUCTS_DIR; };
+		CD3DA4131D9B4302001B53A0 /* scope_guard.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = scope_guard.hpp; sourceTree = "<group>"; };
+/* End PBXFileReference section */
+
+/* Begin PBXFrameworksBuildPhase section */
+		CD3DA4061D9B42F4001B53A0 /* Frameworks */ = {
+			isa = PBXFrameworksBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+/* End PBXFrameworksBuildPhase section */
+
+/* Begin PBXGroup section */
+		CD3DA4001D9B42F4001B53A0 = {
+			isa = PBXGroup;
+			children = (
+				CD3DA4131D9B4302001B53A0 /* scope_guard.hpp */,
+				CD3DA40A1D9B42F4001B53A0 /* Products */,
+			);
+			sourceTree = "<group>";
+		};
+		CD3DA40A1D9B42F4001B53A0 /* Products */ = {
+			isa = PBXGroup;
+			children = (
+				CD3DA4091D9B42F4001B53A0 /* scope_guard */,
+			);
+			name = Products;
+			sourceTree = "<group>";
+		};
+/* End PBXGroup section */
+
+/* Begin PBXNativeTarget section */
+		CD3DA4081D9B42F4001B53A0 /* scope_guard */ = {
+			isa = PBXNativeTarget;
+			buildConfigurationList = CD3DA4101D9B42F4001B53A0 /* Build configuration list for PBXNativeTarget "scope_guard" */;
+			buildPhases = (
+				CD3DA4051D9B42F4001B53A0 /* Sources */,
+				CD3DA4061D9B42F4001B53A0 /* Frameworks */,
+				CD3DA4071D9B42F4001B53A0 /* CopyFiles */,
+			);
+			buildRules = (
+			);
+			dependencies = (
+			);
+			name = scope_guard;
+			productName = scope_guard;
+			productReference = CD3DA4091D9B42F4001B53A0 /* scope_guard */;
+			productType = "com.apple.product-type.tool";
+		};
+/* End PBXNativeTarget section */
+
+/* Begin PBXProject section */
+		CD3DA4011D9B42F4001B53A0 /* Project object */ = {
+			isa = PBXProject;
+			attributes = {
+				LastUpgradeCheck = 0720;
+				ORGANIZATIONNAME = "Sam Jaffe";
+				TargetAttributes = {
+					CD3DA4081D9B42F4001B53A0 = {
+						CreatedOnToolsVersion = 7.2.1;
+					};
+				};
+			};
+			buildConfigurationList = CD3DA4041D9B42F4001B53A0 /* Build configuration list for PBXProject "scope_guard" */;
+			compatibilityVersion = "Xcode 3.2";
+			developmentRegion = English;
+			hasScannedForEncodings = 0;
+			knownRegions = (
+				en,
+			);
+			mainGroup = CD3DA4001D9B42F4001B53A0;
+			productRefGroup = CD3DA40A1D9B42F4001B53A0 /* Products */;
+			projectDirPath = "";
+			projectRoot = "";
+			targets = (
+				CD3DA4081D9B42F4001B53A0 /* scope_guard */,
+			);
+		};
+/* End PBXProject section */
+
+/* Begin PBXSourcesBuildPhase section */
+		CD3DA4051D9B42F4001B53A0 /* Sources */ = {
+			isa = PBXSourcesBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+/* End PBXSourcesBuildPhase section */
+
+/* Begin XCBuildConfiguration section */
+		CD3DA40E1D9B42F4001B53A0 /* Debug */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				ALWAYS_SEARCH_USER_PATHS = NO;
+				CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
+				CLANG_CXX_LIBRARY = "libc++";
+				CLANG_ENABLE_MODULES = YES;
+				CLANG_ENABLE_OBJC_ARC = YES;
+				CLANG_WARN_BOOL_CONVERSION = YES;
+				CLANG_WARN_CONSTANT_CONVERSION = YES;
+				CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
+				CLANG_WARN_EMPTY_BODY = YES;
+				CLANG_WARN_ENUM_CONVERSION = YES;
+				CLANG_WARN_INT_CONVERSION = YES;
+				CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+				CLANG_WARN_UNREACHABLE_CODE = YES;
+				CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+				CODE_SIGN_IDENTITY = "-";
+				COPY_PHASE_STRIP = NO;
+				DEBUG_INFORMATION_FORMAT = dwarf;
+				ENABLE_STRICT_OBJC_MSGSEND = YES;
+				ENABLE_TESTABILITY = YES;
+				GCC_C_LANGUAGE_STANDARD = gnu99;
+				GCC_DYNAMIC_NO_PIC = NO;
+				GCC_NO_COMMON_BLOCKS = YES;
+				GCC_OPTIMIZATION_LEVEL = 0;
+				GCC_PREPROCESSOR_DEFINITIONS = (
+					"DEBUG=1",
+					"$(inherited)",
+				);
+				GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+				GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
+				GCC_WARN_UNDECLARED_SELECTOR = YES;
+				GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
+				GCC_WARN_UNUSED_FUNCTION = YES;
+				GCC_WARN_UNUSED_VARIABLE = YES;
+				MACOSX_DEPLOYMENT_TARGET = 10.10;
+				MTL_ENABLE_DEBUG_INFO = YES;
+				ONLY_ACTIVE_ARCH = YES;
+				SDKROOT = macosx;
+			};
+			name = Debug;
+		};
+		CD3DA40F1D9B42F4001B53A0 /* Release */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				ALWAYS_SEARCH_USER_PATHS = NO;
+				CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
+				CLANG_CXX_LIBRARY = "libc++";
+				CLANG_ENABLE_MODULES = YES;
+				CLANG_ENABLE_OBJC_ARC = YES;
+				CLANG_WARN_BOOL_CONVERSION = YES;
+				CLANG_WARN_CONSTANT_CONVERSION = YES;
+				CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
+				CLANG_WARN_EMPTY_BODY = YES;
+				CLANG_WARN_ENUM_CONVERSION = YES;
+				CLANG_WARN_INT_CONVERSION = YES;
+				CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+				CLANG_WARN_UNREACHABLE_CODE = YES;
+				CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+				CODE_SIGN_IDENTITY = "-";
+				COPY_PHASE_STRIP = NO;
+				DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+				ENABLE_NS_ASSERTIONS = NO;
+				ENABLE_STRICT_OBJC_MSGSEND = YES;
+				GCC_C_LANGUAGE_STANDARD = gnu99;
+				GCC_NO_COMMON_BLOCKS = YES;
+				GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+				GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
+				GCC_WARN_UNDECLARED_SELECTOR = YES;
+				GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
+				GCC_WARN_UNUSED_FUNCTION = YES;
+				GCC_WARN_UNUSED_VARIABLE = YES;
+				MACOSX_DEPLOYMENT_TARGET = 10.10;
+				MTL_ENABLE_DEBUG_INFO = NO;
+				SDKROOT = macosx;
+			};
+			name = Release;
+		};
+		CD3DA4111D9B42F4001B53A0 /* Debug */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				PRODUCT_NAME = "$(TARGET_NAME)";
+			};
+			name = Debug;
+		};
+		CD3DA4121D9B42F4001B53A0 /* Release */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				PRODUCT_NAME = "$(TARGET_NAME)";
+			};
+			name = Release;
+		};
+/* End XCBuildConfiguration section */
+
+/* Begin XCConfigurationList section */
+		CD3DA4041D9B42F4001B53A0 /* Build configuration list for PBXProject "scope_guard" */ = {
+			isa = XCConfigurationList;
+			buildConfigurations = (
+				CD3DA40E1D9B42F4001B53A0 /* Debug */,
+				CD3DA40F1D9B42F4001B53A0 /* Release */,
+			);
+			defaultConfigurationIsVisible = 0;
+			defaultConfigurationName = Release;
+		};
+		CD3DA4101D9B42F4001B53A0 /* Build configuration list for PBXNativeTarget "scope_guard" */ = {
+			isa = XCConfigurationList;
+			buildConfigurations = (
+				CD3DA4111D9B42F4001B53A0 /* Debug */,
+				CD3DA4121D9B42F4001B53A0 /* Release */,
+			);
+			defaultConfigurationIsVisible = 0;
+		};
+/* End XCConfigurationList section */
+	};
+	rootObject = CD3DA4011D9B42F4001B53A0 /* Project object */;
+}