<commit_before>//
//  CCRxTouchEvent.cpp
//  cocos-rx
//
//  Created by gamako on 2014/08/28.
//
//

#include "CCRxTouchEvent.h"

namespace rx=rxcpp;
namespace rxu=rxcpp::util;
namespace rxsc=rxcpp::schedulers;
namespace rxsub=rxcpp::subjects;

USING_NS_CC;

namespace CCRx {

    namespace touchObservable_detail {
        struct touchObservable_internal {
            rxsub::subject<std::tuple<Touch*, TouchEventObservable>> subject;
            RefPtr<Node> target;
            
            touchObservable_internal(Node* target) : subject(), target(target) {}
            touchObservable_internal(const touchObservable_internal& rhs) : subject(rhs.subject), target(rhs.target) {}
            touchObservable_internal(const touchObservable_internal&& rhs) : subject(rhs.subject), target(rhs.target) {}
            touchObservable_internal(rxsub::subject<std::tuple<Touch*, TouchEventObservable>> subject, Node* target) : subject(std::move(subject)), target(target) {}
            
            ~touchObservable_internal() {
            }
            
        private:
            touchObservable_internal() {}
        };
    }
    
    rx::observable<std::tuple<Touch*, TouchEventObservable>> touchEventObservable(Node* targetNode, std::function<bool(Touch*)> isBegan /* = nullptr */, bool isSwallow /* = shallow */) {
        typedef rx::resource<touchObservable_detail::touchObservable_internal> resource_type;
        return rx::observable<>::scope(
                                       [targetNode] () {
                                           return resource_type(touchObservable_detail::touchObservable_internal(targetNode));
                                       },
                                       [isSwallow, isBegan] (resource_type r) {
                                           
                                           auto subscriber = r.get().subject.get_subscriber();
                                           
                                           auto listener = RefPtr<EventListenerTouchOneByOne>{EventListenerTouchOneByOne::create()};
                                           
                                           if (isSwallow) {
                                               listener->setSwallowTouches(isSwallow);
                                           }
                                           
                                           listener->onTouchBegan = [isBegan, listener, subscriber](Touch* t, Event*) -> bool {
                                               if (isBegan) {
                                                   if (!isBegan(t)) {
                                                       return false;
                                                   }<commit_msg>fix touch event move constructer<commit_after>//
//  CCRxTouchEvent.cpp
//  cocos-rx
//
//  Created by gamako on 2014/08/28.
//
//

#include "CCRxTouchEvent.h"

namespace rx=rxcpp;
namespace rxu=rxcpp::util;
namespace rxsc=rxcpp::schedulers;
namespace rxsub=rxcpp::subjects;

USING_NS_CC;

namespace CCRx {

    namespace touchObservable_detail {
        struct touchObservable_internal {
            rxsub::subject<std::tuple<Touch*, TouchEventObservable>> subject;
            RefPtr<Node> target;
            
            touchObservable_internal(Node* target) : subject(), target(target) {}
            touchObservable_internal(const touchObservable_internal& rhs) : subject(rhs.subject), target(rhs.target) {}
            touchObservable_internal(const touchObservable_internal&& rhs) : subject(std::move(rhs.subject)), target(std::move(rhs.target)) {}
            touchObservable_internal(rxsub::subject<std::tuple<Touch*, TouchEventObservable>> subject, Node* target) : subject(std::move(subject)), target(target) {}
            
            ~touchObservable_internal() {
            }
            
        private:
            touchObservable_internal() {}
        };
    }
    
    rx::observable<std::tuple<Touch*, TouchEventObservable>> touchEventObservable(Node* targetNode, std::function<bool(Touch*)> isBegan /* = nullptr */, bool isSwallow /* = shallow */) {
        typedef rx::resource<touchObservable_detail::touchObservable_internal> resource_type;
        return rx::observable<>::scope(
                                       [targetNode] () {
                                           return resource_type(touchObservable_detail::touchObservable_internal(targetNode));
                                       },
                                       [isSwallow, isBegan] (resource_type r) {
                                           
                                           auto subscriber = r.get().subject.get_subscriber();
                                           
                                           auto listener = RefPtr<EventListenerTouchOneByOne>{EventListenerTouchOneByOne::create()};
                                           
                                           if (isSwallow) {
                                               listener->setSwallowTouches(isSwallow);
                                           }
                                           
                                           listener->onTouchBegan = [isBegan, listener, subscriber](Touch* t, Event*) -> bool {
                                               if (isBegan) {
                                                   if (!isBegan(t)) {
                                                       return false;
                                                   }
{'fraction_non_alphanumeric': 0.09384587619563256, 'fraction_numerical': 0.0028875654214040787, 'mean_word_length': 1.3275934481310374, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 56, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5185552', 'n_tokens_mistral': 1226, 'n_tokens_neox': 1189, 'n_words': 200}