polserver/pol-core/bscript/fmodule.h

66 lines
1.3 KiB
C
Raw Permalink Normal View History

/** @file
*
* @par History
*/
2016-02-11 22:54:43 +01:00
#ifndef FMODULE_H
#define FMODULE_H
#include <map>
#include <stddef.h>
2016-02-11 22:54:43 +01:00
#include <string>
#include <vector>
#include "../clib/boostutils.h"
#include "../clib/maputil.h"
namespace Pol
{
namespace Bscript
{
class UserFunction;
2016-02-11 22:54:43 +01:00
class ModuleFunction
{
public:
boost_utils::function_name_flystring name;
unsigned nargs;
int funcidx; // according to the executor, what's its function index
2016-02-11 22:54:43 +01:00
// compiler only:
UserFunction* uf; // compiler only
bool used; // compiler only
2016-02-11 22:54:43 +01:00
ModuleFunction( const char* fname, int nargs, UserFunction* uf );
~ModuleFunction() = default;
};
2016-02-11 22:54:43 +01:00
class FunctionalityModule
{
public:
bool have_indexes;
std::vector<ModuleFunction*> functions;
2016-02-11 22:54:43 +01:00
// compiler only:
typedef std::map<std::string, ModuleFunction*, Clib::ci_cmp_pred> FunctionsByName;
FunctionsByName functionsByName;
std::vector<ModuleFunction*> used_functions;
std::vector<UserFunction*> owned_userfuncs;
2016-02-11 22:54:43 +01:00
boost_utils::function_name_flystring modulename;
2016-02-11 22:54:43 +01:00
bool isFunc( const char* funcName, ModuleFunction** pmf, int* funcidx );
explicit FunctionalityModule( const char* modname );
~FunctionalityModule();
2016-02-11 22:54:43 +01:00
void addFunction( const char* funcname, int nparams, UserFunction* uf = nullptr );
void fillFunctionsByName();
2016-02-11 22:54:43 +01:00
private:
FunctionalityModule( const FunctionalityModule& );
};
}
2016-02-11 22:54:43 +01:00
}
#endif