Skip to content

Commit 7d4d300

Browse files
committed
Implement construct and destruct interfaces.
These interfaces are responsible for object creation and destruction calling the relevant constructors/destructors. Fixes #16. Fixes #17.
1 parent a33de58 commit 7d4d300

File tree

3 files changed

+460
-21
lines changed

3 files changed

+460
-21
lines changed

include/clang/Interpreter/InterOp.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ namespace InterOp {
2121
using TCppFuncAddr_t = void*;
2222
using TCppSema_t = void*;
2323
using TInterp_t = void*;
24+
using TCppObject_t = void*;
2425
typedef void (*CallFuncWrapper_t)(void*, int, void**, void*);
2526

2627
/// Enables or disables the debugging printouts on stderr.
@@ -243,6 +244,20 @@ namespace InterOp {
243244
}
244245

245246
std::vector<long int> GetDimensions(TCppType_t type);
247+
248+
/// Allocates memory for a given class.
249+
TCppObject_t Allocate(TCppScope_t scope);
250+
251+
/// Deallocates memory for a given class.
252+
void Deallocate(TCppScope_t scope, TCppObject_t address);
253+
254+
/// Creates an object of class \c scope and calls its default constructor. If
255+
/// \c arena is set it uses placement new.
256+
TCppObject_t Construct(TInterp_t interp, TCppScope_t scope,
257+
void* arena = nullptr);
258+
259+
/// Calls the destructor of object of type \c type.
260+
void Destruct(TInterp_t interp, TCppObject_t This, TCppScope_t type);
246261
} // end namespace InterOp
247262

248263
#endif // INTEROP_INTEROP_H

0 commit comments

Comments
 (0)