xref: /aoo4110/main/basic/source/inc/filefmt.hxx (revision b1cdbd2c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _SB_FILEFMT_HXX
25 #define _SB_FILEFMT_HXX
26 
27 #include <tools/solar.h>
28 
29 class SvStream;
30 
31 // Version  2: Datentyp des Returnwerts fuer Publics
32 // Version  3: neue Opcodes
33 // Version  4: neue Opcodes
34 // Version  5: Bug (Ansprung von STATIC-Variablen im Init-Code)
35 // Version  6: Neue Opcodes und Bug (Globals anlegen, ohne BASIC zu beenden)
36 // Version  7: Korrektur im WITH-Parsing
37 // Version  8: Korrektur im IF-Parsing
38 // Version  9: Init-Code auch mit LEAVE beenden, wenn keine SUB/FUNCTION folgt
39 // Version  A: #36374 Bei DIM AS NEW... auch Variablen anlegen
40 // Version  B: #40689 Static umgestellt
41 // Version  C: #41606 Bug bei Static
42 // Version  D: #42678 Bug bei RTL-Function spc
43 // Version  E: #56204 DCREATE, um auch bei DIM AS NEW Arrays anzulegen
44 // Version  F: #57844 Einfuehrung von SvNumberformat::StringToDouble
45 // Version 10: #29955 For-Schleifen-Level in Statement-PCodes generieren
46 // Version 11: #29955 Wegen Build-Inkonsistenzen Neu-Compilieren erzwingen
47 
48 #define B_LEGACYVERSION 0x00000011L
49 #define B_CURVERSION 0x00000012L
50 #define B_EXT_IMG_VERSION 0x00000012L
51 
52 // Eine Datei enthaelt entweder einen Modul- oder einen Library-Record.
53 // Diese Records enthalten wiederum weitere Records. Jeder Record hat
54 // den folgenden Header:
55 
56 //  sal_uInt16 Kennung
57 //  sal_uInt32 Laenge des Records ohne Header
58 //  sal_uInt16 Anzahl Unterelemente
59 
60 // Alle Datei-Offsets in Records sind relativ zum Start des Moduls!
61 
62 #define B_LIBRARY		0x4C42		// BL Library Record
63 #define	B_MODULE		0x4D42		// BM Module Record
64 #define	B_NAME			0x4E4D		// MN module name
65 #define	B_COMMENT		0x434D		// MC comment
66 #define	B_SOURCE		0x4353		// SC source code
67 #define	B_PCODE			0x4350		// PC p-code
68 #define	B_OLDPUBLICS 	0x7550		// Pu publics
69 #define	B_PUBLICS 		0x5550		// PU publics
70 #define	B_POOLDIR 		0x4450		// PD symbol pool directory
71 #define	B_SYMPOOL		0x5953		// SY symbol pool
72 #define	B_STRINGPOOL	0x5453		// ST symbol pool
73 #define	B_LINERANGES	0x524C		// LR line ranges for publics
74 #define	B_MODEND		0x454D		// ME module end
75 #define	B_SBXOBJECTS	0x5853		// SX SBX objects
76 
77 #define	EXTENDED_BINARY_MODULES
78 #ifdef  EXTENDED_BINARY_MODULES
79 #define	B_EXTSOURCE		0x5345		// ES extended source
80 #endif
81 
82 // Ein Library Record enthaelt nur Module Records
83 //  sal_uInt16 Kennung BL
84 //  sal_uInt32 Laenge des Records
85 //  sal_uInt16 Anzahl Module
86 
87 // Ein Modul-Record enthaelt alle anderen Recordtypen
88 //  sal_uInt16 Kennung BM
89 //  sal_uInt32 Laenge des Records
90 //  sal_uInt16 1
91 // Daten:
92 //  sal_uInt32 Versionsnummer
93 //  sal_uInt32 Zeichensatz
94 //  sal_uInt32 Startadresse Initialisierungscode
95 //  sal_uInt32 Startadresse Sub Main
96 //  sal_uInt32 Reserviert
97 //  sal_uInt32 Reserviert
98 
99 // Modulname, Kommentar und Quellcode:
100 //  sal_uInt16 Kennung MN, MC oder SC
101 //  sal_uInt32 Laenge des Records
102 //  sal_uInt16 1
103 // Daten:
104 //  String-Instanz
105 
106 // P-Code:
107 //  sal_uInt16 Kennung PC
108 //  sal_uInt32 Laenge des Records
109 //  sal_uInt16 1
110 // Daten:
111 //  Der P-Code als Bytesack
112 
113 // Alle Symbole und Strings werden in einem String-Pool gehalten.
114 // Verweise auf diese Strings sind in Form eines Indexes in diesen Pool.
115 
116 // Liste aller Publics:
117 //  sal_uInt16 Kennung PU oder Pu
118 //  sal_uInt32 Laenge des Records
119 //  sal_uInt16 Anzahl der Publics
120 // Daten fuer jeden Public-Eintrag:
121 //  sal_uInt16 String-Index
122 //  sal_uInt32 Startadresse im P-Code-Image (sal_uInt16 fuer alte Publics)
123 //  sal_uInt16 Datentyp des Returnwertes (ab Version 2)
124 
125 // Verzeichnis der Symbol-Tabellen:
126 //  sal_uInt16 Kennung SP
127 //  sal_uInt32 Laenge des Records
128 //  sal_uInt16 Anzahl der Symboltabellen
129 // Daten fuer jede Symboltabelle:
130 //  sal_uInt16 Stringindex des Namens
131 //  sal_uInt16 Anzahl Symbole
132 //  sal_uInt16 Scope-Kennung
133 
134 // Symboltabelle:
135 //  sal_uInt16 Kennung SY
136 //  sal_uInt32 Laenge des Records
137 //  sal_uInt16 Anzahl der Symbole
138 // Daten:
139 //  sal_uInt16 Stringindex des Namens
140 //  sal_uInt16 Anzahl Symbole
141 // Daten fuer jedes Symbol:
142 //  sal_uInt16 Stringindex des Namens
143 //  sal_uInt16 Datentyp
144 //  sal_uInt16 Laenge bei STRING*n-Symbolen (0x8000: STATIC-Variable)
145 
146 // Stringpool:
147 //  sal_uInt16 Kennung ST
148 //  sal_uInt32 Laenge des Records
149 //  sal_uInt16 Anzahl der Strings
150 // Daten fuer jeden String:
151 //  sal_uInt32 Offset in den Block aller Strings
152 // Danach folgt der Block aller Strings, die dort als ASCIIZ-Strings liegen.
153 
154 // Line Ranges:
155 //  sal_uInt16 Kennung LR
156 //  sal_uInt32 Laenge des Records
157 //  sal_uInt16 Anzahl der Strings
158 // Daten fuer jedes Public:
159 //  sal_uInt16 1. Zeile (Sub XXX)
160 //  sal_uInt16 2. Zeile (End Sub)
161 
162 // SBX-Objekte:
163 // sal_uInt16 Anzahl Objekte
164 // ....   Objektdaten
165 
166 ////////////////////////////////////////////////////////////////////////////
167 
168 // Service-Routinen (in IMAGE.CXX)
169 
170 sal_Bool  SbGood( SvStream& r );
171 sal_uIntPtr SbOpenRecord( SvStream&, sal_uInt16 nSignature, sal_uInt16 nElem );
172 void  SbCloseRecord( SvStream&, sal_uIntPtr );
173 
174 #endif
175