diff --git a/launchers/macosx/obj-cpp/16x16-Itoopie Transparent.png b/launchers/macosx/I2PLauncher/16x16-Itoopie Transparent.png similarity index 100% rename from launchers/macosx/obj-cpp/16x16-Itoopie Transparent.png rename to launchers/macosx/I2PLauncher/16x16-Itoopie Transparent.png diff --git a/launchers/macosx/obj-cpp/AppDelegate.h b/launchers/macosx/I2PLauncher/AppDelegate.h similarity index 100% rename from launchers/macosx/obj-cpp/AppDelegate.h rename to launchers/macosx/I2PLauncher/AppDelegate.h diff --git a/launchers/macosx/obj-cpp/Info.plist b/launchers/macosx/I2PLauncher/Info.plist similarity index 100% rename from launchers/macosx/obj-cpp/Info.plist rename to launchers/macosx/I2PLauncher/Info.plist diff --git a/launchers/macosx/obj-cpp/ItoopieTransparent.png b/launchers/macosx/I2PLauncher/ItoopieTransparent.png similarity index 100% rename from launchers/macosx/obj-cpp/ItoopieTransparent.png rename to launchers/macosx/I2PLauncher/ItoopieTransparent.png diff --git a/launchers/macosx/obj-cpp/JavaHelper.h b/launchers/macosx/I2PLauncher/JavaHelper.h similarity index 100% rename from launchers/macosx/obj-cpp/JavaHelper.h rename to launchers/macosx/I2PLauncher/JavaHelper.h diff --git a/launchers/macosx/obj-cpp/PidWatcher.h b/launchers/macosx/I2PLauncher/PidWatcher.h similarity index 100% rename from launchers/macosx/obj-cpp/PidWatcher.h rename to launchers/macosx/I2PLauncher/PidWatcher.h diff --git a/launchers/macosx/obj-cpp/README.md b/launchers/macosx/I2PLauncher/README.md similarity index 100% rename from launchers/macosx/obj-cpp/README.md rename to launchers/macosx/I2PLauncher/README.md diff --git a/launchers/macosx/obj-cpp/RouterTask.h b/launchers/macosx/I2PLauncher/RouterTask.h similarity index 100% rename from launchers/macosx/obj-cpp/RouterTask.h rename to launchers/macosx/I2PLauncher/RouterTask.h diff --git a/launchers/macosx/obj-cpp/RouterTask.mm b/launchers/macosx/I2PLauncher/RouterTask.mm similarity index 100% rename from launchers/macosx/obj-cpp/RouterTask.mm rename to launchers/macosx/I2PLauncher/RouterTask.mm diff --git a/launchers/macosx/obj-cpp/fullBuild.sh b/launchers/macosx/I2PLauncher/fullBuild.sh similarity index 100% rename from launchers/macosx/obj-cpp/fullBuild.sh rename to launchers/macosx/I2PLauncher/fullBuild.sh diff --git a/launchers/macosx/obj-cpp/images/128x128-Itoopie Transparent.png b/launchers/macosx/I2PLauncher/images/128x128-Itoopie Transparent.png similarity index 100% rename from launchers/macosx/obj-cpp/images/128x128-Itoopie Transparent.png rename to launchers/macosx/I2PLauncher/images/128x128-Itoopie Transparent.png diff --git a/launchers/macosx/obj-cpp/images/128x128-Itoopie Transparent@2x.png b/launchers/macosx/I2PLauncher/images/128x128-Itoopie Transparent@2x.png similarity index 100% rename from launchers/macosx/obj-cpp/images/128x128-Itoopie Transparent@2x.png rename to launchers/macosx/I2PLauncher/images/128x128-Itoopie Transparent@2x.png diff --git a/launchers/macosx/obj-cpp/images/16x16-Itoopie Transparent@2x.png b/launchers/macosx/I2PLauncher/images/16x16-Itoopie Transparent@2x.png similarity index 100% rename from launchers/macosx/obj-cpp/images/16x16-Itoopie Transparent@2x.png rename to launchers/macosx/I2PLauncher/images/16x16-Itoopie Transparent@2x.png diff --git a/launchers/macosx/obj-cpp/images/256x256-Itoopie Transparent.png b/launchers/macosx/I2PLauncher/images/256x256-Itoopie Transparent.png similarity index 100% rename from launchers/macosx/obj-cpp/images/256x256-Itoopie Transparent.png rename to launchers/macosx/I2PLauncher/images/256x256-Itoopie Transparent.png diff --git a/launchers/macosx/obj-cpp/images/256x256-Itoopie Transparent@2x.png b/launchers/macosx/I2PLauncher/images/256x256-Itoopie Transparent@2x.png similarity index 100% rename from launchers/macosx/obj-cpp/images/256x256-Itoopie Transparent@2x.png rename to launchers/macosx/I2PLauncher/images/256x256-Itoopie Transparent@2x.png diff --git a/launchers/macosx/obj-cpp/images/32x32-Itoopie Transparent.png b/launchers/macosx/I2PLauncher/images/32x32-Itoopie Transparent.png similarity index 100% rename from launchers/macosx/obj-cpp/images/32x32-Itoopie Transparent.png rename to launchers/macosx/I2PLauncher/images/32x32-Itoopie Transparent.png diff --git a/launchers/macosx/obj-cpp/images/32x32-Itoopie Transparent@2x.png b/launchers/macosx/I2PLauncher/images/32x32-Itoopie Transparent@2x.png similarity index 100% rename from launchers/macosx/obj-cpp/images/32x32-Itoopie Transparent@2x.png rename to launchers/macosx/I2PLauncher/images/32x32-Itoopie Transparent@2x.png diff --git a/launchers/macosx/obj-cpp/images/512x512-Itoopie Transparent.png b/launchers/macosx/I2PLauncher/images/512x512-Itoopie Transparent.png similarity index 100% rename from launchers/macosx/obj-cpp/images/512x512-Itoopie Transparent.png rename to launchers/macosx/I2PLauncher/images/512x512-Itoopie Transparent.png diff --git a/launchers/macosx/obj-cpp/images/512x512-Itoopie Transparent@2x.png b/launchers/macosx/I2PLauncher/images/512x512-Itoopie Transparent@2x.png similarity index 100% rename from launchers/macosx/obj-cpp/images/512x512-Itoopie Transparent@2x.png rename to launchers/macosx/I2PLauncher/images/512x512-Itoopie Transparent@2x.png diff --git a/launchers/macosx/obj-cpp/images/AppIcon.icns b/launchers/macosx/I2PLauncher/images/AppIcon.icns similarity index 100% rename from launchers/macosx/obj-cpp/images/AppIcon.icns rename to launchers/macosx/I2PLauncher/images/AppIcon.icns diff --git a/launchers/macosx/obj-cpp/main.mm b/launchers/macosx/I2PLauncher/main.mm similarity index 100% rename from launchers/macosx/obj-cpp/main.mm rename to launchers/macosx/I2PLauncher/main.mm diff --git a/launchers/macosx/obj-cpp/portcheck.h b/launchers/macosx/I2PLauncher/portcheck.h similarity index 100% rename from launchers/macosx/obj-cpp/portcheck.h rename to launchers/macosx/I2PLauncher/portcheck.h diff --git a/launchers/macosx/obj-cpp/include/any.hpp b/launchers/macosx/include/any.hpp similarity index 100% rename from launchers/macosx/obj-cpp/include/any.hpp rename to launchers/macosx/include/any.hpp diff --git a/launchers/macosx/obj-cpp/include/fn.h b/launchers/macosx/include/fn.h similarity index 100% rename from launchers/macosx/obj-cpp/include/fn.h rename to launchers/macosx/include/fn.h diff --git a/launchers/macosx/obj-cpp/include/strutil.hpp b/launchers/macosx/include/strutil.hpp similarity index 100% rename from launchers/macosx/obj-cpp/include/strutil.hpp rename to launchers/macosx/include/strutil.hpp diff --git a/launchers/macosx/obj-cpp/include/subprocess.hpp b/launchers/macosx/include/subprocess.hpp similarity index 100% rename from launchers/macosx/obj-cpp/include/subprocess.hpp rename to launchers/macosx/include/subprocess.hpp diff --git a/launchers/macosx/obj-cpp/include/traits.hpp b/launchers/macosx/include/traits.hpp similarity index 100% rename from launchers/macosx/obj-cpp/include/traits.hpp rename to launchers/macosx/include/traits.hpp diff --git a/launchers/macosx/obj-cpp/Makefile b/launchers/macosx/obj-cpp/Makefile deleted file mode 100644 index f87e0c5db98e9fdc6aa081483efb6d27101ea56a..0000000000000000000000000000000000000000 --- a/launchers/macosx/obj-cpp/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -CXX=clang++ - -CXXFLAGS= -std=c++14 -g -Wall -mmacosx-version-min=10.10 -INCLUDEDIRS=-I./include -I/usr/local/include -I/usr/include -SOURCES=main.mm StatusItemButton.mm CRunner.cpp -LDFLAGS=-framework CoreFoundation -framework Foundation -framework Cocoa - -i2plauncher: - $(CXX) $(CXXFLAGS) $(INCLUDEDIRS) $(LDFLAGS) -o i2plauncher $(SOURCES) - -clean: - rm -f i2plauncher diff --git a/launchers/macosx/obj-cpp/StatusItemButton.h b/launchers/macosx/obj-cpp/StatusItemButton.h deleted file mode 100644 index 93086f5e4fb0870658fa7a6ef1870d40d032d30e..0000000000000000000000000000000000000000 --- a/launchers/macosx/obj-cpp/StatusItemButton.h +++ /dev/null @@ -1,27 +0,0 @@ -#pragma once - -#import <Cocoa/Cocoa.h> - -/** - * - * This is a class representing the "image" in the systray. - * - * - * **/ -@class StatusItemButton; - -@protocol StatusItemButtonDelegate <NSObject> - -- (void) statusItemButtonLeftClick: (StatusItemButton *) button; -- (void) statusItemButtonRightClick: (StatusItemButton *) button; - -@end - -@interface StatusItemButton : NSView - -@property (strong, nonatomic) NSImage *image; -@property (unsafe_unretained) id<StatusItemButtonDelegate> delegate; - -- (instancetype) initWithImage: (NSImage *) image; - -@end diff --git a/launchers/macosx/obj-cpp/StatusItemButton.mm b/launchers/macosx/obj-cpp/StatusItemButton.mm deleted file mode 100644 index 249d2e251a3c66e38ebfac626c70f56f84fae3e0..0000000000000000000000000000000000000000 --- a/launchers/macosx/obj-cpp/StatusItemButton.mm +++ /dev/null @@ -1,39 +0,0 @@ -#import <AppKit/AppKit.h> - -#import "StatusItemButton.h" - -@implementation StatusItemButton - -- (instancetype) initWithImage: (NSImage *) image { - self = [super initWithFrame:NSMakeRect(0, 0, image.size.width, image.size.height)]; - if (self) { - self.image = image; - } - return self; -} - -- (void) setImage:(NSImage *)image { - _image = image; - [self setNeedsDisplay:YES]; -} - -- (void) drawRect: (NSRect) dirtyRect { - NSSize imageSize = self.image.size; - CGFloat x = (self.bounds.size.width - imageSize.width)/2; - CGFloat y = (self.bounds.size.height - imageSize.height) /2; - NSRect drawnRect = NSMakeRect(x, y, imageSize.width, imageSize.height); - - [self.image drawInRect:drawnRect fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1.0]; -} - -- (void) mouseDown:(NSEvent *)theEvent { - [self.delegate statusItemButtonLeftClick:self]; -} - -- (void) rightMouseDown:(NSEvent *)theEvent { - [self.delegate statusItemButtonRightClick:self]; -} - - - -@end diff --git a/launchers/macosx/obj-cpp/build.ninja b/launchers/macosx/obj-cpp/build.ninja deleted file mode 100644 index 88df88db3aa71dfe2e754f1ed98dfd989cf6f31d..0000000000000000000000000000000000000000 --- a/launchers/macosx/obj-cpp/build.ninja +++ /dev/null @@ -1,56 +0,0 @@ -cxx = clang++ -cflags = -std=c++14 -g -Wall -I./include -I./include/neither -I/usr/local/include -I/usr/include $ - -Wno-unused-function -Wno-incomplete-implementation -Wno-unused-variable -mmacosx-version-min=10.10 -ldflags = -framework CoreFoundation -framework Foundation -framework Cocoa -g -rdynamic - - -pool link_pool - depth = 4 - -rule cxx - command = $cxx $cflags -c $in -o $out - description = CC $out - -rule link - command = $cxx $ldflags -o $out $in - description = LINK $out - pool = link_pool - -rule ar - command = ar crsT $out $in - description = AR $out - -rule cleanup - command = rm -fr *.o clauncher I2PLauncher.app base.zip - -# TODO: There must exists a cleaner way to solve this. -rule bundledir - command = mkdir -p I2PLauncher.app/Contents/{MacOS,Resources,Frameworks} $ - && cp Info.plist I2PLauncher.app/Contents/Info.plist $ - && cd ../../../pkg-temp && zip -r7 ../base.zip * && cd - && mv ../../../base.zip base.zip $ - && cp base.zip I2PLauncher.app/Contents/Resources/base.zip $ - && cp ../target/scala-2.11/routerLauncher-assembly-0.1.0-SNAPSHOT.jar I2PLauncher.app/Contents/Resources/launcher.jar - -rule copytobundledir - command = cp clauncher I2PLauncher.app/Contents/MacOS/I2PLauncher - -rule copyimgtobundle - command = cp ItoopieTransparent.png I2PLauncher.app/Contents/Resources/ItoopieTransparent.png - -rule builddir - command = mkdir -p build - -build main.o: cxx main.mm -build StatusItemButton.o: cxx StatusItemButton.mm -build RouterTask.o: cxx RouterTask.mm - -build clean: cleanup - -build bundle: bundledir -build copytobundle: copytobundledir | bundle clauncher - -build clauncher: link main.o StatusItemButton.o RouterTask.o - -build appbundle: copyimgtobundle | clauncher bundle copytobundle - -default appbundle diff --git a/launchers/macosx/obj-cpp/include/neither/either.hpp b/launchers/macosx/obj-cpp/include/neither/either.hpp deleted file mode 100644 index d212b99a50bac513879f63c9fd43df11e950925f..0000000000000000000000000000000000000000 --- a/launchers/macosx/obj-cpp/include/neither/either.hpp +++ /dev/null @@ -1,264 +0,0 @@ -#ifndef NEITHER_EITHER_HPP -#define NEITHER_EITHER_HPP - -#include <memory> -#include <type_traits> -#include "traits.hpp" -#include "maybe.hpp" - -#include "traits.hpp" -#include "maybe.hpp" - -namespace neither { - -template<class T> -constexpr T max(T x, T y) { - return x>y ? x : y; -} - -template<class T> -struct Left { - T value; -}; - -template<class T> -constexpr Left<T> left(T const& x) { - return {x}; -} - -template<class T> -Left<T> left(T&& x) { - return { std::move(x) }; -} - -template<class T> -struct Right { - T value; -}; - -template<class T> -constexpr Right<T> right(T const& x) { - return {x}; -} - - -template<class T> -Right<T> right(T&& x) { - return { std::move(x) }; -} - -template<class L, class R> -struct Either { - - union { - L leftValue; - R rightValue; - }; - - bool const isLeft = 0; - - constexpr Either( Left<L> const& l ) - : leftValue{l.value} - , isLeft(1) - {} - - constexpr Either( Right<R> const& r ) - : rightValue{r.value} - , isLeft(0) - {} - - Either(Left<L> && l ) - : leftValue{std::move(l.value)} - , isLeft(1) - {} - - Either( Right<R> && r ) - : rightValue{std::move(r.value)} - , isLeft(0) - {} - - constexpr Either( Either<L, R> const& e ) - : isLeft(e.isLeft) { - if (isLeft) { - new (&leftValue)L(e.leftValue); - } else { - new (&rightValue)R(e.rightValue); - } - } - - Either( Either<L, R>&& e ) - : isLeft(e.isLeft) { - if (isLeft) { - new (&leftValue)L(std::move(e.leftValue)); - } else { - new (&rightValue)R(std::move(e.rightValue)); - } - } - - ~Either() { - if (isLeft) { - leftValue.~L(); - } else { - rightValue.~R(); - } - } - - constexpr auto left() const -> Maybe<L> { - return isLeft ? - maybe(leftValue) : - maybe(); - } - - constexpr auto right() const -> Maybe<R> { - return isLeft ? - maybe() : - maybe(rightValue); - } - - static constexpr auto leftOf( L const& l ) { - return Either<L, R>{ neither::left(l) }; - } - - static constexpr auto rightOf( R const& r ) { - return Either<L, R>{ neither::right(r) }; - } - - static constexpr auto leftOf( L && l ) { - return Either<L, R>{ neither::left(std::move(l)) }; - } - - static constexpr auto rightOf( R && r ) { - return Either<L, R>{ neither::right(std::move(r)) }; - } - - template< - class L2 = L, - class R2 = R> - constexpr auto join() const - -> decltype( - isCopyable((L2)leftValue, (R2)rightValue), - std::declval<std::common_type_t<L2, R2>>() - ) { - return isLeft ? leftValue : rightValue; - } - - template< - class L2 = L, - class R2 = R> - auto join()&& - -> std::common_type_t<L2, R2> { - return isLeft ? std::move(leftValue) : std::move(rightValue); - } - - template<class LeftF, class RightF> - constexpr auto join(LeftF const& leftCase, RightF const& rightCase) const - -> decltype( isLeft? leftCase( leftValue ) : rightCase( rightValue ) ) { - return isLeft ? leftCase( leftValue ) : rightCase( rightValue ); - } - - template<class F, class L2=L, class R2=R> - constexpr auto leftMap(F const& leftCase) const& - -> Either<decltype(leftCase( isCopyable((L2)leftValue, (R2)rightValue) )), R2> { - using NextEither = Either<decltype(leftCase(leftValue)), R2>; - return isLeft ? - NextEither::leftOf( leftCase( leftValue ) ) : - NextEither::rightOf( rightValue ); - } - - template<class F, class L2=L, class R2=R> - auto leftMap(F const& leftCase)&& -> Either<decltype(leftCase(std::move(leftValue))), R2> { - using NextEither = Either<decltype(leftCase(std::move(leftValue))), R2>; - return isLeft ? - NextEither::leftOf(leftCase(std::move(leftValue))) : - NextEither::rightOf( std::move(rightValue) ); - } - - template<class F, class L2=L, class R2=R> - constexpr auto rightMap(F const& rightCase) const& -> Either<L, decltype(rightCase(isCopyable((R2)rightValue, (L2)leftValue)))> { - using NextEither = Either<L, decltype(rightCase(rightValue))>; - return isLeft ? - NextEither::leftOf( leftValue ) : - NextEither::rightOf( rightCase( rightValue ) ); - } - - template<class F, class L2=L, class R2=R> - auto rightMap(F const& rightCase)&& -> Either<L2, decltype(rightCase(std::move((R2)rightValue)))> { - using NextEither = Either<L, decltype(rightCase(std::move(rightValue)))>; - return isLeft ? - NextEither::leftOf( std::move(leftValue) ) : - NextEither::rightOf( rightCase( std::move(rightValue) ) ); - } - - template<class LeftCase, class L2=L, class R2=R> - constexpr auto leftFlatMap(LeftCase const& leftCase) const& - -> decltype( ensureEitherRight(leftCase(isCopyable((L2)leftValue)), isCopyable((R2)rightValue))) { - using NextEither = decltype(leftCase(leftValue)); - - if (!*this) { - return leftCase( leftValue ); - } - - return NextEither::rightOf(rightValue); - } - - template<class RightCase, class L2 = L, class R2 = R> - constexpr auto rightFlatMap(RightCase const& rightCase) const& - -> decltype( ensureEitherLeft(rightCase(isCopyable((R2)rightValue)), isCopyable((L2)leftValue))) { - using NextEither = decltype(rightCase(rightValue)); - - if (*this) { - return rightCase( rightValue ); - } - - return NextEither::leftOf(leftValue); - } - - template<class LeftCase, class L2 = L, class R2 = R> - auto leftFlatMap(LeftCase const& leftCase)&& - -> decltype( ensureEitherRight(leftCase(std::move(leftValue)), std::move(rightValue))) { - using NextEither = decltype(leftCase(std::move(leftValue))); - - if (!*this) { - return leftCase( std::move(leftValue) ); - } - - return NextEither::rightOf(std::move(rightValue)); - } - - template<class RightCase, class L2=L, class R2=R> - auto rightFlatMap(RightCase const& rightCase)&& - -> decltype( ensureEitherLeft(rightCase(std::move(rightValue)), std::move(leftValue))) { - using NextEither = decltype(rightCase(std::move(rightValue))); - - if (*this) { - return rightCase(std::move(rightValue)); - } - - return NextEither::leftOf(std::move(leftValue)); - } - - constexpr operator bool()const { return !isLeft; } -}; - -template <typename L, typename R> -bool operator == (Either<L, R> const& a, Either<L, R> const& b) { - if (a.isLeft) { - if (b.isLeft) { - return a.left() == b.left(); - } - } else { - if (!b.isLeft) { - return a.right() == b.right(); - } - } - return false; -} - -template <typename L, typename R> -bool operator != (Either<L, R> const& a, Either<L, R> const& b) { - return !(a == b); -} - -} - -#endif diff --git a/launchers/macosx/obj-cpp/include/neither/lift.hpp b/launchers/macosx/obj-cpp/include/neither/lift.hpp deleted file mode 100644 index a3405cb8f74aa38c76f2cf00d96c5a138d1c0898..0000000000000000000000000000000000000000 --- a/launchers/macosx/obj-cpp/include/neither/lift.hpp +++ /dev/null @@ -1,60 +0,0 @@ -#include "either.hpp" - -namespace neither { - - template<class L, class R> - constexpr bool hasValue(Either<L,R> const& e) { - return e; - } - - - template<class T> - constexpr bool hasValue(Maybe<T> const& m) { - return m; - } - - template<class T> - constexpr bool hasValue(T) { - return true; - } - - - - template<class L, class R> - constexpr R unpack(Either<L, R> const& e) { - return e.rightValue; - } - - - template<class T> - constexpr T unpack(Maybe<T> const& m) { - return m.value; - } - - template<class T> - constexpr T unpack(T const& x) { - return x; - } - - constexpr auto allTrue(bool x=true, bool y=true) { - return x && y; - } - - - template<class X, class...Xs> - auto allTrue(X x, Xs...xs) { - return allTrue(x, allTrue(xs...)); - } - - template<class F> - auto lift(F const& f) { - return [f](auto...x) -> decltype(maybe(f(unpack(x)...))) { - if ( allTrue(hasValue(x)...) ) { - return f(unpack(x)...); - } - - return maybe(); - }; - } - -} diff --git a/launchers/macosx/obj-cpp/include/neither/maybe.hpp b/launchers/macosx/obj-cpp/include/neither/maybe.hpp deleted file mode 100644 index 316da3b0c354df8e583beaa3fcc7a663e35911c9..0000000000000000000000000000000000000000 --- a/launchers/macosx/obj-cpp/include/neither/maybe.hpp +++ /dev/null @@ -1,117 +0,0 @@ -#ifndef NEITHER_MAYBE_HPP -#define NEITHER_MAYBE_HPP - -#include <memory> -#include <cassert> -#include "traits.hpp" - -namespace neither { - -template <class T> struct Maybe; - -template <> struct Maybe<void> {}; - -template <class T> struct Maybe { - - union { - T value; - }; - - bool const hasValue = 0; - - constexpr Maybe() : hasValue{0} {} - - constexpr Maybe(T const& value) : value{value}, hasValue{1} {} - constexpr Maybe(T&& value) : value{std::move(value)}, hasValue{1} {} - - constexpr Maybe(Maybe<void>) : hasValue{0} {} - - constexpr Maybe(Maybe<T> const &o) : hasValue{o.hasValue} { - if (o.hasValue) { - new (&value)T(o.value); - } - } - - ~Maybe() { - if (hasValue) { - value.~T(); - } - } - - constexpr T get(T defaultValue) { - return hasValue ? value : defaultValue; - } - - constexpr T unsafeGet() { - assert(hasValue && "unsafeGet must not be called on an empty Maybe"); - return value; - } - - template<class F> - constexpr auto map(F const &f) const& - -> Maybe<decltype(f(isCopyable(value)))> { - using ReturnType = decltype(f(value)); - if (!hasValue) { - return Maybe<ReturnType>(); - } - return Maybe<ReturnType>(f(value)); - } - - - template<class F> - auto map(F const& f)&& - -> Maybe<decltype(f(std::move(value)))> { - using ReturnType = decltype(f(std::move(value))); - if (!hasValue) { - return Maybe<ReturnType>(); - } - return Maybe<ReturnType>(f(std::move(value))); - } - - template <class F> - constexpr auto flatMap(F const& f) const& - -> decltype(ensureMaybe(f(value))) { - using ReturnType = decltype(f(value)); - if (!hasValue) { - return ReturnType(); - } - - return f(value); - } - - template <class F> - constexpr auto flatMap(F const& f)&& - -> decltype(ensureMaybe(f(std::move(value)))) { - using ReturnType = decltype(f(std::move(value))); - if (!hasValue) { - return ReturnType(); - } - - return f(std::move(value)); - } - - constexpr operator bool() const { return hasValue; } -}; - -template <typename T> -auto maybe(T value) -> Maybe<T> { return {value}; } - -template <typename T = void> -auto maybe() -> Maybe<T> { return {}; } - -template <typename T> -bool operator == (Maybe<T> const& a, Maybe<T> const& b) { - if (a.hasValue) { - return b.hasValue && a.value == b.value; - } - return !b.hasValue; -} - -template <typename T> -bool operator != (Maybe<T> const& a, Maybe<T> const& b) { - return !(a == b); -} - -} - -#endif diff --git a/launchers/macosx/obj-cpp/include/neither/neither.hpp b/launchers/macosx/obj-cpp/include/neither/neither.hpp deleted file mode 100644 index 0b8f27ed705991ecc084b8d096d9c311604afbee..0000000000000000000000000000000000000000 --- a/launchers/macosx/obj-cpp/include/neither/neither.hpp +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef NEITHER_NEITHER_HPP -#define NEITHER_NEITHER_HPP - -#include "either.hpp" -#include "lift.hpp" -#include "maybe.hpp" -#include "traits.hpp" -#include "try.hpp" - -#endif diff --git a/launchers/macosx/obj-cpp/include/neither/try.hpp b/launchers/macosx/obj-cpp/include/neither/try.hpp deleted file mode 100644 index 27b23061b7c5efaee41f1c472fd51fd154735bbf..0000000000000000000000000000000000000000 --- a/launchers/macosx/obj-cpp/include/neither/try.hpp +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef NEITHER_TRY_HPP -#define NEITHER_TRY_HPP - -#include <functional> -#include "either.hpp" - -namespace neither { - -template <class E, class F, class... X> -auto Try(F const &f, X &&... x) - -> Either<E, decltype(f(std::forward<X>(x)...))> { - try { - return right(f(std::forward<X>(x)...)); - } catch (E const &e) { - return left(e); - } -} -} - -#endif