I noticed that, while this compiles and works fine:
'Generated with PluriBASIC 6.0.74371.0
$ filename "classes_on_macros.exe"
uses rtl32
class _newclass
public sys h
method constructor(int s)
h = getmemory(s)
print h
end method
method destructor()
freememory(h)
end method
function hPtr() as sys
print h
return h
end function
end class
MACRO ELEMENT_INIT(src, trg)
int i = sizeof(trg)
new _newclass buf(i)
src = buf.hPtr()
END MACRO
FUNCTION PBMAIN() AS INT
INT myvar
INT target
ELEMENT_INIT(myvar, target)
END FUNCTION
PBMAIN() ' invoke entry point
This does not compile:
'Generated with PluriBASIC 6.0.74371.0
$ filename "classes_on_macros.exe"
uses rtl32
class _newclass
public sys h
method constructor(int s)
h = getmemory(s)
print h
end method
method destructor()
freememory(h)
end method
function hPtr() as sys
print h
return h
end function
end class
MACRO ELEMENT_INIT(src, trg)
MACRO .readyup(src, trg buf, i, h)
int i = sizeof(trg)
new _newclass buf(i)
src = buf.hPtr()
END MACRO
END MACRO
FUNCTION PBMAIN() AS INT
INT myvar
INT target
ELEMENT_INIT.readyup(myvar, target)
END FUNCTION
PBMAIN() ' invoke entry point
It seems like when it is inside a child macro, the code does not recognize the class function hPtr().