IonicWind Software

Aurora Compiler => General Discussion => Topic started by: sapero on May 31, 2007, 10:55:37 AM

Title: Problems with unicode strings
Post by: sapero on May 31, 2007, 10:55:37 AM
Hello, I have some small problems with unicode strings in Aurora.
Let say, i want to create a string with embedded quotes, like name.exe "%1"
If I do it in this way, it will be incorrect (syntax error):
wstring *pwsz = L"name.exe \"%1\""

2. escape characters.
- L"\\" produces two back-slashes.
- L"\aaaaa\aaaa" is working without warnings.
- L"\x00" isn't working as expected: '\',  'x' and '00' is added to string.
- no way to add small 'T' after '\', so  L"\\t" won't work.

3. alignment, the one with I spend much time to find a bug. When mixing multibyte and unicode strings, any api that uses unicode string can fail, if the string is not aligned on 2-byte boundary
string *s = "ab";
wstring *w = L".text";
RegOpenKetExW(HKEY_CLASSES_ROOT, w, ...) // will fail here

I have two fixes for this. extend the string s with extra NULL character: s = "ab\x00"; or insert a dummy string pointer before the unicode string:
string *s = "ab"; // 3 bytes in .data section
string *dummy = ""; // 1 byte in .data
wstring *w = L".text";
RegOpenKetExW(HKEY_CLASSES_ROOT, w, ...) // ok!

The second hack : redefine 'db' to 'dw' in assembly code, to force all strings to be WORD aligned:

sub this_is_last_sub_in_module()
{
   return;
}

#emit %define db dw

I know the parser uses "segment .data use32 align=4" but the last token is ignored, here is nothing aligned, maybe the first label is. I have also a extra macro to force all subroutines to be aligned on DWORD boundary:%macro .ef 0
.ef
align 4
%endm
Everytime a subroutine ends, here is a local '.ef' label that forces the next label to be propertly aligned.
Title: Re: Problems with unicode strings
Post by: sapero on June 17, 2007, 10:58:00 AM
I've found another problem in aurora rc1 parser.
Already finished converting fmod headers and started with examples. The first was 3d. Strange! The first api FMOD_System_Create crashes the app.
sub main()
{
    FMOD_SYSTEM     *system;
    result = FMOD_System_Create(&system);

The problem was (found in assembly output):
   push dword [__imp_system]
   call [__imp_FMOD_System_Create]

So instead pointer to local variable named 'system', a pointer to crt api system(char*) was passed. The include file stdlib.inc was also included.
Problem solved - renamed variable system.
Title: Re: Problems with unicode strings
Post by: Ionic Wind Support Team on June 17, 2007, 02:11:52 PM
Because there is a SYSTEM command, which takes precedence.