mirror of
https://github.com/polserver/polserver
synced 2026-08-13 08:23:08 -04:00
* all except pol * pol and includes under defines * something weird has happened * remove own folder from include searchpath * fixed remaining, adapted include style for external headers * missing include
96 lines
2.7 KiB
C++
96 lines
2.7 KiB
C++
#pragma once
|
|
|
|
#include <memory>
|
|
#include <set>
|
|
|
|
#include "clib/refptr.h"
|
|
#include "bscript/bobject.h"
|
|
#include "bscript/bstruct.h"
|
|
#include "bscript/eprog.h"
|
|
|
|
namespace Pol::Bscript
|
|
{
|
|
class BFunctionRef;
|
|
|
|
class BClassInstance final : public BStruct
|
|
{
|
|
using base = BStruct;
|
|
|
|
public:
|
|
BClassInstance( ref_ptr<EScriptProgram> program, int index, std::weak_ptr<ValueStackCont> globals,
|
|
unsigned int pid );
|
|
BClassInstance( const BClassInstance& B );
|
|
~BClassInstance() override = default;
|
|
|
|
public:
|
|
size_t sizeEstimate() const override;
|
|
ref_ptr<EScriptProgram> prog() const;
|
|
unsigned index() const;
|
|
// returns nullptr if no function found
|
|
BFunctionRef* makeMethod( const char* method_name );
|
|
|
|
// Inherited from BStruct
|
|
const char* typetag() const override;
|
|
|
|
std::set<unsigned> constructors_called;
|
|
|
|
public: // Class Machinery
|
|
const char* typeOf() const override;
|
|
u8 typeOfInt() const override;
|
|
BObjectImp* copy() const override;
|
|
bool isTrue() const override;
|
|
BObjectImp* call_method( const char* methodname, Executor& ex ) override;
|
|
BObjectImp* call_method_id( const int id, Executor& ex, bool forcebuiltin = false ) override;
|
|
BObjectRef get_member_id( const int id ) override;
|
|
// void packonto( std::string& os ) const override; // no serialization
|
|
|
|
std::string getStringRep() const override;
|
|
|
|
private:
|
|
ref_ptr<EScriptProgram> prog_;
|
|
unsigned int index_;
|
|
unsigned int pid_;
|
|
|
|
public:
|
|
std::weak_ptr<ValueStackCont> globals;
|
|
};
|
|
|
|
class BClassInstanceRef final : public BObjectImp
|
|
{
|
|
public:
|
|
BClassInstanceRef( BClassInstance* );
|
|
|
|
private:
|
|
~BClassInstanceRef() override = default;
|
|
|
|
public: // Class Machinery
|
|
size_t sizeEstimate() const override;
|
|
const char* typeOf() const override;
|
|
u8 typeOfInt() const override;
|
|
BObjectImp* copy() const override;
|
|
bool isTrue() const override;
|
|
BObjectImp* call_method( const char* methodname, Executor& ex ) override;
|
|
BObjectImp* call_method_id( const int id, Executor& ex, bool forcebuiltin = false ) override;
|
|
BObjectRef get_member_id( const int id ) override;
|
|
|
|
std::string getStringRep() const override;
|
|
|
|
ContIterator* createIterator( BObject* pIterVal ) override;
|
|
|
|
BObjectRef OperSubscript( const BObject& obj ) override;
|
|
BObjectRef set_member( const char* membername, BObjectImp* value, bool copy ) override;
|
|
BObjectRef get_member( const char* membername ) override;
|
|
BObjectRef operDotPlus( const char* name ) override;
|
|
BObjectRef operDotMinus( const char* name ) override;
|
|
BObjectRef operDotQMark( const char* name ) override;
|
|
BObjectImp* array_assign( BObjectImp* idx, BObjectImp* target, bool copy ) override;
|
|
|
|
inline BClassInstance* instance() const { return class_instance_.get(); }
|
|
|
|
|
|
private:
|
|
ref_ptr<BClassInstance> class_instance_;
|
|
};
|
|
|
|
|
|
} // namespace Pol::Bscript
|