newruntime: make dynamic destructors compatible with C++
This commit is contained in:
parent
5dea7c5ad7
commit
831626be85
2 changed files with 4 additions and 3 deletions
|
|
@ -1255,7 +1255,7 @@ proc genObjectInfoV2(m: BModule, t, origType: PType, name: Rope; info: TLineInfo
|
||||||
else:
|
else:
|
||||||
d = rope("NIM_NIL")
|
d = rope("NIM_NIL")
|
||||||
addf(m.s[cfsVars], "TNimType $1;$n", [name])
|
addf(m.s[cfsVars], "TNimType $1;$n", [name])
|
||||||
addf(m.s[cfsTypeInit3], "$1.destructor = $2; $1.size = sizeof($3); $1.name = $4;$n", [
|
addf(m.s[cfsTypeInit3], "$1.destructor = (void*)$2; $1.size = sizeof($3); $1.name = $4;$n", [
|
||||||
name, d, getTypeDesc(m, t), genTypeInfo2Name(m, t)])
|
name, d, getTypeDesc(m, t), genTypeInfo2Name(m, t)])
|
||||||
|
|
||||||
proc genTypeInfo(m: BModule, t: PType; info: TLineInfo): Rope =
|
proc genTypeInfo(m: BModule, t: PType; info: TLineInfo): Rope =
|
||||||
|
|
|
||||||
|
|
@ -27,8 +27,9 @@ hash of ``package & "." & module & "." & name`` to save space.
|
||||||
|
|
||||||
type
|
type
|
||||||
TNimNode {.compilerProc.} = object # to keep the code generator simple
|
TNimNode {.compilerProc.} = object # to keep the code generator simple
|
||||||
|
DestructorProc = proc (p: pointer) {.nimcall, benign.}
|
||||||
TNimType {.compilerProc.} = object
|
TNimType {.compilerProc.} = object
|
||||||
destructor: proc (p: pointer) {.nimcall, benign.}
|
destructor: pointer
|
||||||
size: int
|
size: int
|
||||||
name: cstring
|
name: cstring
|
||||||
PNimType = ptr TNimType
|
PNimType = ptr TNimType
|
||||||
|
|
@ -65,7 +66,7 @@ proc nimRawDispose(p: pointer) {.compilerRtl.} =
|
||||||
|
|
||||||
proc nimDestroyAndDispose(p: pointer) {.compilerRtl.} =
|
proc nimDestroyAndDispose(p: pointer) {.compilerRtl.} =
|
||||||
let d = cast[ptr PNimType](p)[].destructor
|
let d = cast[ptr PNimType](p)[].destructor
|
||||||
if d != nil: d(p)
|
if d != nil: cast[DestructorProc](d)(p)
|
||||||
nimRawDispose(p)
|
nimRawDispose(p)
|
||||||
|
|
||||||
proc isObj(obj: PNimType, subclass: cstring): bool {.compilerproc.} =
|
proc isObj(obj: PNimType, subclass: cstring): bool {.compilerproc.} =
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue