Import "some.lib"- and strings.

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
jassing
Addict
Addict
Posts: 1885
Joined: Wed Feb 17, 2010 12:00 am

Import "some.lib"- and strings.

Post by jassing »

Would this be feasible?
Import "Some.lib"
MyFunc.s( someparame.l, otherparam.s)
endimport

the ".s" signaling the return type from the function.
Yes, I know we can use openlib/getfunction/prototypes, but this would seem very easy, intuitive and, dare I say it, basic, to ease the import/coding.
User avatar
Danilo
Addict
Addict
Posts: 3036
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Re: Import "some.lib"- and strings.

Post by Danilo »

jassing wrote:Import "Some.lib"
MyFunc.s( someparame.l, otherparam.s)
endimport
I would like to add pseudotypes to this request:
Please allow pseudotypes for import functions and prototypes as return type.

Code: Select all

ImportC "Some.lib"
  MyFunc1.p-Ascii   ( arg.p-ascii   )
  MyFunc2.p-Unicode ( arg.p-Unicode )
  MyFunc3.p-utf8    ( arg.p-utf8    )
  MyFunc4.p-bstr    ( arg.p-bstr    )
EndImport

PrototypeC.p-ascii   C_func1()
PrototypeC.p-Unicode C_func2()
PrototypeC.p-utf8    C_func3()
PrototypeC.p-bstr    C_func4()
So PB could catch null-terminated C char* pointers and automatically convert it to PB string. In Ascii and Unicode mode.
In generated ASM, it would be only a call to an internal convert function, directly after calling the function. After that,
we have a PB string. char* = 0 would return an empty PB string.
Post Reply