Loading...
Searching...
No Matches
tbridge.hpp
Go to the documentation of this file.
1
2#pragma once
3
4#include "core/ast/obj.hpp"
9
10namespace by {
11
19 template <typename T> class tbridge: public baseObj {
20 // TODO: how to impement 'as()' on bridge obj:
21 // each tbridge obj has its unique type object. when it got called 'getType()'
22 // it returns its type object.
23 //
24 // however, type object is dynamically belongs to this bridge object, when user
25 // tries to get ttype<T>, it's not derived from ntype so it won't have any 'as()'
26 // func. user can't operate conversion in this way.
28 friend class coreInternal;
29 static_assert(!tifSub<T, baseObj>::is,
30 "parameterized type 'T' shouldn't be a derived class to baseObj. override subs() if it "
31 "is.");
32
33 protected:
37 tbridge(): me(nullptr) {}
38
39 tbridge(T* real, const baseObj* origin = nullptr): super(origin, false), _real(real) {}
40
41 public:
42 tbridge(const me& rhs): super(rhs), _real(rhs._real ? new T(*rhs._real) : nullptr) {}
43
44 ~tbridge() override {
45 if(_ownReal && _real) delete _real;
46 }
47
48 public:
49 T* get() { return _real; }
50
51 const T* get() const { return _real; }
52
53 const baseObj& getOrigin() const override {
54 static tbaseObjOrigin<tbridge<T>> org(
55 tbridger<T, tifSub<typename tadaptiveSuper<T>::super, baseObj>::is>::subs());
56 const baseObj& supers = super::getOrigin();
57 return &supers == this ? org : supers;
58 }
59
60 private:
61 T* _real;
62 nbool _ownReal = _real;
63 };
64} // namespace by
Base class for representing byeol objects.
Definition baseObj.hpp:73
baseObj()=default
Default constructor for baseObj.
Definition coreInternal.hpp:39
User-defined origin type.
Definition origin.hpp:99
C++ native class bridge.
Definition tbridge.hpp:19
tbridge()
Definition tbridge.hpp:37
Definition tnarr.hpp:9
to Top