Just to say thank you for the new release
0.7.0 2025-01-28T14:30:00
:D
Thanks Pierre,
A few tweaks prompted by studying Josés TOM and AFX FreeBasic headers:
You can specify the legacy calling conventions thiscall and fastcall for 32bit compiling.
You can use the term declare inside a type when specifying OOP functions.
You can type int as mytype instead of using typedef.
#macro() .. #endmacro is also supported.
const as string = has been fixed.
Good morning.. Sounds good charles...
QuoteYou can use the term declare inside a type when specifying OOP functions.
You can type int as mytype instead of using typedef.
#macro() .. #endmacro is also supported.
const as string = has been fixed.
Do you have Made examples for your improvements?
const and fastcall still need further adjustment, but I will update again very soon.
const:
const as char c="abc"
print c
#macro:
#macro m(a)
print a " ok"
#endmacro
m(99)
type .. as ..
type int as mytype
dim as mytype x
x=4.6
print x '5
#declare:
type cc
dim as int ii
declare function ff(int n) as int
end type
'
methods of cc
function ff(int n) as int
print n " ok"
end function
end methods
'
dim as cc c
c.ff 123 '123 ok
thiscall
type cc
function ff thiscall (int a, int b, int c) as int
return a+b+c
end function
end type
dim cc c
print c.ff(1,10,100) '111
> You can use the term declare inside a type when specifying OOP functions.
Non OOP functions can also be declared insde a type using the STATIC keyword.
For example, I'm finishing a class called CRichEditCtrl, that creates a subclassed Rich Edit control, and for its callback procedure I'm declaring
' // Static callback procedure
DECLARE STATIC FUNCTION CRichEditCtrlProc (BYVAL hwnd AS HWND, BYVAL uMsg AS UINT, BYVAL wParam AS WPARAM, BYVAL lParam AS LPARAM, BYVAL uIdSubclass AS UINT_PTR, BYVAL dwRefData AS DWORD_PTR) AS LRESULT
What it does is that it will be called as a normal function, without passing the hidden this parameter to it. The advantage is that you have all contained inside the type declaration.
My new class creates a subclassed Rich Edit control, wraps all the Windows Rich Edit messages and will provide access to the other classes that wrap the Text Object Model interfaces.
A further tweak is needed to support Declare static function ...
Another challenge is that o2 static functions are strongly encapsulated (along with static variables.
These are generally not visible outside the class.
However, getting the static function to provide a direct link to the outside world is the best solution, and avoids the need for a wrapper function.
declare function ptr AccessF2(int n) as int 'our interface function
'
type cc
dim as int mi 'property
declare function f1() as int 'method
declare static function f2(int n) as int
end type
methods of cc
=============
dim static ii as int
'
static function f2(int n) as int, link @AccessF2 'linking to the outer function
ii=n
print "f2 " n
end function
function f1() as int
print "f1 " ii
end function
'
end methods
AccessF2(123)
The last example doesn't Work .. linker ..all Others are Working fine
' test 1) static function works
'
static function f2(int n) as int
print "test"
end function
f2(1)
'---------------------------------- //
'
' 2) doesnt work below
'
declare function ptr AccessF2(int n) as int 'our interface function
'
type cc
dim as int mi 'property
declare function f1() as int 'method
declare static function f2(int n) as int
end type
methods of cc
=============
dim static ii as int
' error next line
static function f2(int n) as int, link @AccessF2 'linking to the outer function
ii=n
print "f2 " n
end function
function f1() as int
print "f1 " ii
end function
'
end methods ' error 35 static ' linker found unidentified names
AccessF2(123)
If you remove the f2 function from the type block, it should work. But I'm posting the update later this afternoon.
The more compact version of this example requires no declarations and no separate methods block:. The compiler does the work.
declare function ptr AccessF2(int n) as int
'
type cc
'
dim as int mi
dim as static int ii
'
static function f2(int n) as int, link @AccessF2
ii=n
print "f2 " n
end function
'
function f1() as int
print "f1 " ii
end function
'
end type
AccessF2(123)