DWSTRING.bi - Dynamic null terminated unicode string data type

User projects written in or related to FreeBASIC.
deltarho[1859]
Posts: 1652
Joined: Jan 02, 2017 0:34
Location: UK

Re: DWSTRING.bi - Dynamic null terminated unicode string data type

Postby deltarho[1859] » Jul 11, 2018 4:59

Josep Roca wrote:I use source code and PRIVATE all the time.

So do I, as per 2) Second method.

I put some of my random number generators into libraries and their throughput collapsed.
Juergen Kuehlwein
Posts: 67
Joined: Mar 07, 2018 13:59
Location: Germany

Re: DWSTRING.bi - Dynamic null terminated unicode string data type

Postby Juergen Kuehlwein » Jul 13, 2018 17:11

José´s WinFBX Framework is an optional but recommended part of my IDE. He generously allowed me to extract the dynamic unicode string part for use in my IDE, in case people wouldn´t want to include WinFBX. This is basically the same what DWSTRING.bi contains.

I can confirm that it is working as "advertised" - no bugs so far. The only (in my view acceptable) drawback is, that in some cases fbc doesn´t accept the "CWstr/DWSTRING/USTRING" (whatever you name it) type as string type (In some other cases it does!). Therefore you have to prepend a "*" to variable names in these cases. This is a problem with FreeBASIC not consistently handling types and not a problem of José´s code. I can say that, because i tried myself to fiddle around with his code and had discussions with him about the code. But in the end i had to admit, that, what he found, is the best possible under the given circumstances.

Great work - thanks José


JK
kcvinu
Posts: 173
Joined: Oct 07, 2015 16:44
Location: Keralam, India

Re: DWSTRING.bi - Dynamic null terminated unicode string data type

Postby kcvinu » Sep 17, 2018 20:18

This is my doubt.
When will they add this CWSTR and DWSTR into freebasic core ? After all, these data types are essential for a language.
St_W
Posts: 1436
Joined: Feb 11, 2009 14:24
Location: Austria
Contact:

Re: DWSTRING.bi - Dynamic null terminated unicode string data type

Postby St_W » Sep 18, 2018 10:12

kcvinu wrote:When will they add this CWSTR and DWSTR into freebasic core ? After all, these data types are essential for a language.
I agree that such datatypes should be part of freebasic core, but there are a few issues that prevents to use this implementation. First, it is Windows-only while FreeBasic aims at providing a cross-platform development environment. Second, the FB runtime is currently implemented in C (although there exists an attempt to reimplement it in FB) and deeply integrated in the compiler - quite some additional work would be necessary to integrate this in the compiler and extend all built-in methods accepting these additional string types.
kcvinu
Posts: 173
Joined: Oct 07, 2015 16:44
Location: Keralam, India

Re: DWSTRING.bi - Dynamic null terminated unicode string data type

Postby kcvinu » Sep 18, 2018 18:57

@St_W,
Thanks for the reply.
There is a language called Nim. (formerly Nimrod). It is compiled to C. They also targeting to Linux, Windows, and Mac. In Nim, a normal string data type is dynamic UNICODE string.
Juergen Kuehlwein
Posts: 67
Joined: Mar 07, 2018 13:59
Location: Germany

Re: DWSTRING.bi - Dynamic null terminated unicode string data type

Postby Juergen Kuehlwein » Sep 19, 2018 20:56

@St_W

Well, i didn´t have time for inspecting the compiler code thoroughly enough, but i think it would be enough to add "DWSTRING" (and maybe other clones of it) to the known string types, other changes and adaptions shouldn´t be necessary. Internally a DWSTRING is a WSTRING, which the compiler already supports, the DWSTRING type supplies the memory mangement ensuring the buffer size meets the required size (... a dynamic WSTRING). While in some cases the compiler accepts a DWSTRING without any problem, in some others cases it rejects it ("type mismatch"), because it doesn´t recoognize, that it´s in fact a WSTRING.

The current workaround for places, where the compiler doesn´t accept it, is to return a DWSTRING as "content of WSTRING PTR" (which is in effect a WSTRING)

As for the mulitplatform problem: the C-Runtime functions implemented in DWSTRING (e.g wmemmove) could be replaced by universal functions - which is quite some work to do, but possible.

So i think this a desirable and a doable thing!


JK

Return to “Projects”

Who is online

Users browsing this forum: No registered users and 2 guests