Skip to content

Commit 1f0f216

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 9875b65 commit 1f0f216

File tree

3 files changed

+465
-26
lines changed

3 files changed

+465
-26
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.
@@ -249,6 +250,20 @@ namespace InterOp {
249250
}
250251

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

254269
#endif // INTEROP_INTEROP_H

0 commit comments

Comments
 (0)