<commit_before>#pragma once
#include "AnyArray.h"
#include "VarArgs.h"

namespace EasyCpp
{
	class DLL_EXPORT AnyFunction
	{
	public:
		class FunctionBase
		{
		public:
			FunctionBase() {}
			virtual ~FunctionBase() {}
			virtual AnyValue call(const AnyArray& args) = 0;
			virtual std::vector<TypeInfo> getParameterTypes() = 0;
			virtual TypeInfo getReturnType() = 0;
			virtual bool hasVarArgs() = 0;
			virtual bool hasVarReturnValue() = 0;
		};

		template<typename Result, typename... Args>
		class Function : public FunctionBase
		{
		public:
			Function(std::function<Result(Args...)> fn) { _function = fn; }
			virtual ~Function() {}
			virtual AnyValue call(const AnyArray & args) override
			{
				return VarArgs::call(_function, args);
			}
			virtual std::vector<TypeInfo> getParameterTypes() override
			{
				return VarArgs::getTypeInfo<Args...>();
			}
			virtual TypeInfo getReturnType() override
			{
				return TypeInfo::CreateInfo<Result>();
			}
			virtual bool hasVarArgs() override
			{
				return false;
			}
			virtual bool hasVarReturnValue() override
			{
				return false;
			}
		private:
			std::function<Result(Args...)> _function;
		};

		class DynamicFunction : public FunctionBase
		{
		public:
			DynamicFunction(std::function<AnyValue(const AnyArray&)> fn) { _function = fn; }
			virtual ~DynamicFunction() {}
			virtual AnyValue call(const AnyArray & args) override
			{
				return _function(args);
			}
			virtual std::vector<TypeInfo> getParameterTypes() override
			{
				return{};
			}
			virtual TypeInfo getReturnType() override
			{
				return TypeInfo::CreateInfo<std::nullptr_t>();
			}
			virtual bool hasVarArgs() override
			{
				return true;
			}
			virtual bool hasVarReturnValue() override
			{
				return true;
			}
		private:
			std::function<AnyValue(const AnyArray&)> _function;
		};

		AnyFunction(std::shared_ptr<FunctionBase> fn)
			: _fn(fn)
		{}<commit_msg>Added initializer list #63<commit_after>#pragma once
#include "AnyArray.h"
#include "VarArgs.h"

namespace EasyCpp
{
	class DLL_EXPORT AnyFunction
	{
	public:
		class FunctionBase
		{
		public:
			FunctionBase() {}
			virtual ~FunctionBase() {}
			virtual AnyValue call(const AnyArray& args) = 0;
			virtual std::vector<TypeInfo> getParameterTypes() = 0;
			virtual TypeInfo getReturnType() = 0;
			virtual bool hasVarArgs() = 0;
			virtual bool hasVarReturnValue() = 0;
		};

		template<typename Result, typename... Args>
		class Function : public FunctionBase
		{
		public:
			Function(std::function<Result(Args...)> fn)
                :_function(fn)
            {}
			virtual ~Function() {}
			virtual AnyValue call(const AnyArray & args) override
			{
				return VarArgs::call(_function, args);
			}
			virtual std::vector<TypeInfo> getParameterTypes() override
			{
				return VarArgs::getTypeInfo<Args...>();
			}
			virtual TypeInfo getReturnType() override
			{
				return TypeInfo::CreateInfo<Result>();
			}
			virtual bool hasVarArgs() override
			{
				return false;
			}
			virtual bool hasVarReturnValue() override
			{
				return false;
			}
		private:
			std::function<Result(Args...)> _function;
		};

		class DynamicFunction : public FunctionBase
		{
		public:
			DynamicFunction(std::function<AnyValue(const AnyArray&)> fn)
                :_function(fn)
            {}
			virtual ~DynamicFunction() {}
			virtual AnyValue call(const AnyArray & args) override
			{
				return _function(args);
			}
			virtual std::vector<TypeInfo> getParameterTypes() override
			{
				return{};
			}
			virtual TypeInfo getReturnType() override
			{
				return TypeInfo::CreateInfo<std::nullptr_t>();
			}
			virtual bool hasVarArgs() override
			{
				return true;
			}
			virtual bool hasVarReturnValue() override
			{
				return true;
			}
		private:
			std::function<AnyValue(const AnyArray&)> _function;
		};

		AnyFunction(std::shared_ptr<FunctionBase> fn)
			: _fn(fn)
		{}
{'fraction_non_alphanumeric': 0.11862669741224699, 'fraction_numerical': 0.0030745580322828594, 'mean_word_length': 3.4063205417607225, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 27, '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': '5484355', 'n_tokens_mistral': 1473, 'n_tokens_neox': 1185, 'n_words': 283}