<commit_before>// This file is part of SWGANH which is released under the MIT license.
// See file LICENSE or go to http://swganh.com/LICENSE
#pragma once

#include <memory>
#include <string>

#include <boost/python/object.hpp>

#include "swganh/scripting/utilities.h"

namespace swganh {
namespace scripting {
    class PythonScriptCreator
    {
    public:
        PythonScriptCreator(std::string module_name, std::string class_name);

        template<typename T>
        std::shared_ptr<T> operator() ()
        {
            ScopedGilLock lock;
            std::shared_ptr<T> interfaceObj = nullptr;
            try 
            {

        #ifdef _DEBUG
                module_ = boost::python::object(bp::handle<>(PyImport_ReloadModule(module_.ptr())));
        #endif
                
                auto new_instance = module_.attr(class_name_.c_str())();

                if (!new_instance.is_none())
                {
                    T* obj_pointer = boost::python::extract<T*>(new_instance);
                    interfaceObj.reset(obj_pointer, [new_instance] (T*) {});
                }
            }
			catch (bp::error_already_set&)
			{
				swganh::scripting::logPythonException();
			}

            return interfaceObj;
        }

    private:
        std::string module_name_;
        std::string class_name_;
        
        boost::python::object module_;
    };

}}<commit_msg>fix for linux compiling<commit_after>// This file is part of SWGANH which is released under the MIT license.
// See file LICENSE or go to http://swganh.com/LICENSE
#pragma once

#include <memory>
#include <string>

#include <boost/python/object.hpp>

#include "swganh/scripting/utilities.h"

namespace swganh {
namespace scripting {
    class PythonScriptCreator
    {
    public:
        PythonScriptCreator(std::string module_name, std::string class_name);

        template<typename T>
        std::shared_ptr<T> operator() ()
        {
            ScopedGilLock lock;
            std::shared_ptr<T> interfaceObj = nullptr;
            try 
            {

        #ifdef _DEBUG
                module_ = boost::python::object(boost::python::handle<>(PyImport_ReloadModule(module_.ptr())));
        #endif
                
                auto new_instance = module_.attr(class_name_.c_str())();

                if (!new_instance.is_none())
                {
                    T* obj_pointer = boost::python::extract<T*>(new_instance);
                    interfaceObj.reset(obj_pointer, [new_instance] (T*) {});
                }
            }
			catch (boost::python::error_already_set&)
			{
				swganh::scripting::logPythonException();
			}

            return interfaceObj;
        }

    private:
        std::string module_name_;
        std::string class_name_;
        
        boost::python::object module_;
    };

}}
{'fraction_non_alphanumeric': 0.11362032462949895, 'fraction_numerical': 0.0, 'mean_word_length': 2.0615550755939527, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1551806', 'n_tokens_mistral': 840, 'n_tokens_neox': 787, 'n_words': 163}