The WinCE implementation converts the rawbytestring arguments to
unicodestring and calls unicode OS APIs, while the others convert
unicodestring arguments to DefaultFileSystemCodePage and call
single byte OS APIs
+ test for the above
git-svn-id: branches/cpstrrtl@22467 -
RTL units. Comes with a FPCRTL_FILESYSTEM_UTF8 define that can be
activated for targets whose single byte filesystem interface enforces
UTF-8; included in inc/systemh.inc and unix/cwstring.pp until now
+ DefaultFileSystemCodePage variable that holds the code page used for
communicating with the OS single byte file system APIs, and for the
strings returned by those same APIs. Initialized with
o the result of GetACP in the system unit of Windows platforms, except for
WinCE which uses UTF-8 since its file system OS API calls already use
the UTF-16 versions
o CP_UTF8 on Unix platforms with FPCRTL_FILESYSTEM_UTF8 defined, and with
DefaultSystemCodePage on other Unix platforms
o DefaultSystemCodePage on Java/Android JVM targets
+ DefaultRTLFileSystemCodePage variable that holds the code page used to
encode strings returned by RTL routines that return filenames obtained
from OS API calls. By default the same as DefaultFileSystemCodePage on
all platforms. Separate from DefaultFileSystemCodePage for clarity on
platforms that may use either utf-16 or single byte OS API calls to
send/receive file names (such as most Windows platforms)
+ new scpFileSystemSingleByte enum that can be passed to
GetStandardCodePage() to get the default code page for OS single byte file
system APIs, with implementations for Unix and Windows
+ SetMultiByteFileSystemCodePage() procedure to override the value of
DefaultFileSystemCodePage
In principle, in the long run unchanged programs only using generic
ansistrings and unicodestrings should (mostly) behave the same as in
FPC 2.6.0 as far as RTL-level file system APIs are concerned if
they set DefaultFileSystemCodePage and DefaultRTLFileSystemCodePage
to DefaultSystemCodePage at the start of their execution
git-svn-id: branches/cpstrrtl@22466 -
ansistrings, and for adding in some unicodestring support at the same time
(unless in the end only a unicodestring RTL is supported, all the work is
necessary in any case and everything can still be moved around later if
required)
git-svn-id: branches/cpstrrtl@22465 -
* pgenutil.pas, generate_specialization:
* return a generrordef instead of Nil when returning because of an error
* always check "genname" for a generic count string as a mode ObjFPC generic specialized in a mode Delphi unit will already contain a "$X" suffix and only symname will be set.
+ add (corrected) test
git-svn-id: trunk@22462 -
type that contains managed types, but this child doesn't contain any
managed type itself (since r16632, the parent should be considered as a
field of the child in terms of needing initialization/finalization)
git-svn-id: trunk@22461 -
* defcmp.pas, compare_defs_ext:
use the new genericparas list to check whether two specializations of the same generic can be considered equal
+ added test
git-svn-id: trunk@22454 -
The cause of the internal error was the following:
We have a generic in an unit ("A") which uses another unit ("B") in the implementation section and this other unit uses unit A in the interface section. Now the generic is specialized in the interface section of B. This leads to the problem that in unit A when it tries to load the globalsymtable of unit B that globalsymtable will be Nil, because parsing of the interface section is not yet finished. Thus the change in pgenutil.pas, specialization_init: if the unit is still "in_interface" the localsymtable needs to be used instead of the globalsymtable.
This doesn't necessarily lead to a compiling test though, as there is the following possibility:
Unit A contains a generic class/record (with methods) and uses unit B in the implementation section. This unit B also contains a generic class/record (with methods) and uses unit A in the implementation section. Both units contain a specialization of the other unit's generic outside of it's own generics (such that generate_specialization is fully triggered). Let's assume compilation starts with unit A and we reach the uses of unit B. Now compilation switches to unit B and completes as unit A is already registered and in compilation. The problem now is that the generic in unit A still contains unresolved forward declarations as the implementation section of A was not yet parsed which will lead to "forward declaration not solved" errors (Note: Delphi compiles this).
The solution to this is the following: if a generic is specialized from another unit which is not in state ms_compiled then the unit of the specialization needs to wait for the unit of the generic. So the specialization's unit adds itself into a list of waiting units of the generic's unit. Now inside "proc_unit" we need to check whether this module is waiting for other modules and if so avoid "finishing" the unit (which means generating the methods of the specialization, generating assembler code and ultimately freeing the scanner and PPU). Now when the generic's unit finishes we need to check whether other modules are waiting for it and finish them (of course it's a bit more complicated in reality, but that pretty much sums it up).
+ globstat.pas: Added an unit which handles the saving and restoring of the global state which was originally inside "parser.pas, compile" so that Don't Repeat Yourself (DRY) is respected.
* fmodule.pas, tmodule:
+ add fields to keep track of the units the module is waiting for and which modules are waiting for the module
+ add field for the saved global state (raw pointer to avoid circles)
+ add field for the state which is needed to finish the unit (raw pointer to avoid circles)
+ move the code which was used in "parser.pas, compile" after a module was successfully compiled to the new virtual method "end_of_parsing"
+ fppu.pas, tppumodule.end_of_parsing:
free the ppufile here
* pgenutil.pas:
+ add new procedure "maybe_add_waiting_unit" which adds the specialization's unit to the waiting list of the generic if that unit is not yet compiled
* generate_specialization: call the new function when we add a new (true) specialization
* specialization_init: instead of not adding implementation units at all check whether the unit is still parsing the interface section and add the localsymtable in that case
* pmodules.pas:
* change "proc_unit" to a function which returns "true" if the unit was already finished (no need to wait for other units)
+ move the code from "proc_unit" from "generate_specialization_procs" on to a new procedure "finish_unit" which
* this procedure is either called immediately in "proc_unit" if the unit does not need to wait for other units or from "finish_unit" itself if a unit that is waiting for the given unit does no longer wait for another module (special care is taken in proc_unit to avoid circles)
* parser.pas, compile:
* correctly handle the case if an unit is not finished
* use the new global state functionality from globstat.pas
* pay special attention when calling "set_current_module" (see comment at that call)
+ add tests from 22160
+ add test for above mentioned "diamond" case
git-svn-id: trunk@22452 -
when concatenating or comparing CP_ACP strings, because the ansistring
conversion helpers also check for CP_ACP and do the right thing in
that case
* don't convert code pages when comparing CP_ACP strings with
DefaultSystemCodePage strings (mantis #22906)
git-svn-id: trunk@22415 -
hidden parameters while parsing the interface, because they may depend on
the padded size (since the size was not yet padded in the interface and
padded in the implementation, this could result in differences)
git-svn-id: trunk@22414 -