Difference between revisions of "System unit structure/es"

From Lazarus wiki
Jump to navigationJump to search
Line 166: Line 166:
  
  
== Public routines ==
+
== Rutinas públicas ==
  
The following routines are part of System unit interface and are supposed to be implemented fully in platform specific way. Their specification is available in FPC documentation, so they're listed here mostly for completeness sake to provide complete list for porting purposes.
+
Las siguientes rutinas son parte del interface de la unit System y se suponen implementadas completamente en plataformas específicas. Su especificación está disponible en la documentación de FPC, por que que son listadas aquí mayormente para aportar una lista completa con propósito de ser portados
  
=== Directory handling ===
+
=== Manejo de directorios ===
  
Usually implemented in sysdir.inc.
+
Usualmente implementado en sysdir.inc.
  
 
* MkDir
 
* MkDir
Line 179: Line 179:
 
* GetDir
 
* GetDir
  
=== Other ===
+
=== Otros ===
  
 
* Randomize
 
* Randomize
* ParamCount, ParamStr (possibly to be moved to common - <TODO>)
+
* ParamCount, ParamStr (posiblemente para ser movido a common - <TODO>)
 
 
  
 
== Finalization ==
 
== Finalization ==

Revision as of 21:57, 21 August 2009

Estructura de la unit System

(trabajo en progreso - ¡incompleto!)

Esta página trata de documentar funciones y procedimientos que sirven como "interfaces" entre common and platform specific parts of unit System as well as commonly used subroutines for particular tasks performed during unit System initialization and specify their behaviour. This should then serve as specification for mantenedores de plataformas nuevas y ya existentes para asegurar un comportamiento totalmente (tanto como sea posible teniendo en consideración las limitaciones de las plataformas individuales).

Todas las rutinas listadas son mandatorias (at least as stub) a menos que se mencione otra cosa específicamente. Si no se menciona el nombre del fichero fuente habitual que contiene la implementación de la rutina, entonces se supone que hace referencia a system.pas para partes de una plataforma específica y a system.inc para las rutinas compartidas entre plataformas.

Tipos

Los siguientes tipos se asume que están definidos en el interface de la unit System para plataformas específicas:

  • THandle
  • TThreadID
  • TRTLCriticalSection
  • PRTLCriticalSection

Constantes y variables

El siguiente listado incluye contantes y variables mandatorias que han de ser declaradas (y habitualmente inicializadas con valores razonables acordes a una plataforma en particular) para todas las plataformas:

  • LineEnding
  • DirectorySeparator
  • DriveSeparator
  • PathSeparator
  • MaxExitCode
  • MaxPathLen
  • UnusedHandle
  • StdInputHandle
  • StdOutputHandle
  • StdErrorHandle
  • LFNSupport
  • FileNameCaseSensitive
  • CtrlZMarksEof
  • sLineBreak
  • DefaultTextLineBreakStyle
  • ArgC
  • ArgV
  • EnvC
  • EnvP


<TODO>

Initialization

Shared

InitHeap

Implemented in heap.inc.

Initialization of internal structures used by the default heap memory manager. No heap may be used before calling InitHeap.

SysInitExceptions

Initialization of internal structures used by the exception support.

<TODO>

OpenStdIO

Common part of initialization for standard file variables. It's similar to Assign and Reset/Rewrite calls for normal text files, but the files are associated with empty file names and no attempt is made to open the files (they're assumed to be already open).

<TODO>

InitSystemThreads

<TODO>

SetThreadManager

<TODO>

InitHeapMutexes

<TODO>

InitVariantManager

<TODO>

InitWideStringManager

<TODO>

Platform specific

unit initialization

The following tasks are performed:

  • IsLibrary variable initialization (true if running in a shared library, false otherwise)
  • ProcessID and ThreadID variables initialization
  • IsConsole variable initialization (true if running in a text console, false if running in windowed GUI application)
  • ExitProc variable initialization <TODO>
  • Heap initialization (calling shared InitHeap)
  • Initialization of potential procedural variables and/or parameters needed to support System unit routines requiring different implementation depending on detected version of operating system (possibly including dynamic loading of procedures or functions from shared libraries where appropriate) - see OS aware RTL
  • InOutRes variable initialization (set to 0)
  • Environment variables initialization (EnvC and EnvP), usually by calling InitEnvironment - only needed for platforms not providing access to these variables natively
  • Internal thread manager is initialized by calling InitSystemThreads
  • Internal variant manager is initialized by calling InitVariantManager
  • Internal widestring manager is initialized by calling InitWideStringManager

InitEnvironment

Only needed for platforms not providing access to EnvC and EnvP variables natively.

Procedure checks amount of environment variables and stores it in EnvC. Then memory for EnvP^ is allocated from heap (array of EnvC + 1 items of type PChar - the list pointer will point to nil). Finally the individual items in the array are initialized with PChars pointing to null terminated strings containing the environment variable name, equal sign and the environment variable value. Memory for the individual null terminated strings may be allocated from heap for these strings and they may be copied there if needed (i.e. if the particular platform doesn't provide pointer to a fixed location for these strings in required format).

InitArguments

Only needed for platforms not providing access to ArgC, ArgV and/or CmdLine variables natively.

<TODO>

SysInitStdIO

Initialization of standard file variables (Input, Output, ErrOutput, StdOut and StdErr).

<TODO>


InitSystemThreads

<TODO>

General tasks

Platform specific

File handling

Usually implemented in file sysfile.inc.

Do_Close
Do_Erase
Do_Rename
Do_Read
Do_Write
Do_FilePos
Do_Seek
Do_SeekEnd
Do_FileSize
Do_Truncate
Do_Open
Do_IsDevice

Heap management

SysOSAlloc
SysOSFree

Threading Support

SysInitThreadVar
SysRelocateThreadVar

Other

System_Exit

Rutinas públicas

Las siguientes rutinas son parte del interface de la unit System y se suponen implementadas completamente en plataformas específicas. Su especificación está disponible en la documentación de FPC, por que que son listadas aquí mayormente para aportar una lista completa con propósito de ser portados

Manejo de directorios

Usualmente implementado en sysdir.inc.

  • MkDir
  • RmDir
  • ChDir
  • GetDir

Otros

  • Randomize
  • ParamCount, ParamStr (posiblemente para ser movido a common - <TODO>)

Finalization

Shared

InternalExit

<TODO>

FinalizeHeap

<TODO>

Platform specific

FinalDeallocation

<TODO>