Since this is also a problem between 32 bit and 64 bit, im going to post it here instead of opening a new thread...
feel free to move it to it's own thread if it is worthy of such promotion.
The following is code that PluriBASIC generates. When using rtl32, it works fine,
but when using rtl64, the app crashes when sending the string pointer as a parameter for
"BYREFPAR". Somehow the engine does not like the pointer. Maybe i am sending a pointer not big enough to
hold the 64bit string address.
Please ignore the fact that the class is not freeing strings properly. I simplified the generated code by hand
to make it easier to follow.
What can i be doing wrong?
'Generated with PluriBASIC 6.0.74371.0
$ filename "array_system.exe"
uses rtl64
Declare Function PluriBASICMessageBox Lib "user32.dll" Alias "MessageBoxA"
FUNCTION MSGBOX(string sText, sys mOptions = 0, string sCaption = "PluriBASIC") AS LONG
FUNCTION = PluriBASICMessageBox(null, sText, sCaption, mOptions)
END FUNCTION
#def __dim1 (d1-bnd[1])
#def __dim2 (d2-bnd[3])
#def __dim3 (d3-bnd[5])
#def __class_nam_def class _arr_%1
macro __declare_array_type(dtype)
__class_nam_def(dtype)
int dims ' Number of dimensions
int elems ' Number of elements.
int slength ' length of strings.
int ispointer ' is pointer flag.
sys hBuffer ' Address of the buffer
sys hCustAddr ' Address provided by the inline code.
int BuffLen ' length of the buffer in bytes
int bnd[10] ' bounds.
function redim(int p, int * d, n)
int i
elems = 0
for i = 1 to n step 2
bnd[i+0] = d[i+0]
bnd[i+1] = d[i+1]
elems += (d[i+1]-d[i+0])
next
int nBufLen = (elems * sizeof(sys)) + 32
sys nBuffer = getmemory(nBufLen)
int eBfCopy = BuffLen
if BuffLen
if BuffLen>nBufLen then
eBfCopy = nBufLen
end if
copy nBufLen, BuffLen, eBfCopy
freememory hBuffer
endif
hBuffer = nBuffer
BuffLen = nBufLen
end function
method constructor(int * d, n, isptr, slen, sys hAddr)
ispointer = isptr
slength = slen
hCustAddr = hAddr
dims = n / 2
this.redim(0, d, n)
end method
function destructor()
freememory(hBuffer)
hBuffer = 0
BuffLen = 0
end function
'======================================================================
function c(int d1, d2, d3, dtype v)
dtype dt at (hBuffer + 32)
dt(__dim1 * __dim2 + __dim3) = v
end function
function c(int d1, d2, d3) as dtype
dtype dt at (hBuffer + 32)
return dt(__dim1 * __dim2 + __dim3)
end function
'======================================================================
function p(int d1, d2, d3) as dtype*
dtype dt at (hBuffer + 32)
return @dt(__dim1 * __dim2 + __dim3)
end function
end class
end macro
__declare_array_type(bstring)
SUB BYREFPAR(BYREF ss AS STRING, BYVAL _ByValue_s2 AS STRING)
STRING s2 = _ByValue_s2
ss = "Changed in the SUB"
s2 = "Changed in the SUB"
END SUB
FUNCTION PBMAIN() AS INT
new _arr_bstring sss(int{-10, 100, 0, 100, 0, 100}, countof, 0, 0, 0)
sss.c(5,5,5) = "Original contents 1"
sss.c(5,5,6) = "Original contents 2"
BYREFPAR(sss.p(5,5,5), sss.c(5,5,6))
MSGBOX(sss.c(5,5,5), 0, sss.c(5,5,6)) ' should display one modified and one unmodified.
END FUNCTION
PBMAIN() ' invoke entry point