Skip to content

Commit c8ae0da

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 b008bbe commit c8ae0da

File tree

3 files changed

+473
-32
lines changed

3 files changed

+473
-32
lines changed

include/clang/Interpreter/CppInterOp.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ namespace Cpp {
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 Cpp {
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 Cpp
253268

254269
#endif // CPPINTEROP_CPPINTEROP_H

0 commit comments

Comments
 (0)