xref: /haiku/docs/develop/build/rc/beres-deres.rst (revision 9f3bdf3d039430b5172c424def20ce5d9f7367d4)
1*9f3bdf3dSAdrien DestuguesDifferences with beres/deres
2*9f3bdf3dSAdrien Destugues############################
3*9f3bdf3dSAdrien Destugues
4*9f3bdf3dSAdrien DestuguesSome of your old rdef files may fail to compile with rc. Besides different command line arguments,
5*9f3bdf3dSAdrien Destuguesrc also has slightly different syntax and semantics. These changes were made to allow for the future
6*9f3bdf3dSAdrien Destuguesexpansion of the rdef grammar and to make resource scripts easier to write and understand. The
7*9f3bdf3dSAdrien Destuguescompiler should be backwards compatible with the majority of old scripts, but in some cases it was
8*9f3bdf3dSAdrien Destuguesnecessary to break stuff.
9*9f3bdf3dSAdrien Destugues
10*9f3bdf3dSAdrien DestuguesDifferences with beres
11*9f3bdf3dSAdrien Destugues======================
12*9f3bdf3dSAdrien Destugues
13*9f3bdf3dSAdrien DestuguesWe allow the \0 escape in string literals.
14*9f3bdf3dSAdrien Destugues
15*9f3bdf3dSAdrien DestuguesOur handling of the minus sign is more restrictive; we don't treat it like a unary minus operator,
16*9f3bdf3dSAdrien Destugueswhich means you may only put one minus in front of a number to negate it (i.e. "- -10" is an error).
17*9f3bdf3dSAdrien Destugues
18*9f3bdf3dSAdrien Destuguesberes allows #define statements, but apparently ignores them. The compiler reports no error, but
19*9f3bdf3dSAdrien Destuguesany symbols you define are not recognized later on. We don't allow #defines (yet).
20*9f3bdf3dSAdrien Destugues
21*9f3bdf3dSAdrien Destuguesberes allows you to put enum symbols in resource data, and replaces the symbol with its value. For
22*9f3bdf3dSAdrien Destuguessome reason, it lets you assign any kind of data to enum symbols, such as strings and floats. Since
23*9f3bdf3dSAdrien Destuguesthat is not valid C/C++ syntax, librdef does not allow this. As a result, it does not make much
24*9f3bdf3dSAdrien Destuguessense for us to support enum symbols in resource data.
25*9f3bdf3dSAdrien Destugues
26*9f3bdf3dSAdrien DestuguesWe only allow a few type casts, but enough to be backwards compatible. beres allows you to cast
27*9f3bdf3dSAdrien Destuguesfrom bool to all other types, between strings and numeric types, etc. The usefulness of this is
28*9f3bdf3dSAdrien Destugueslimited, so to keep things simple librdef doesn't allow that.
29*9f3bdf3dSAdrien Destugues
30*9f3bdf3dSAdrien DestuguesThere is no need to put parentheses around a type code, even for simple data; beres sometimes
31*9f3bdf3dSAdrien Destuguesrequires the parens and sometimes it doesn't. With rc, they are always optional (preferred notation
32*9f3bdf3dSAdrien Destuguesis without the parens).
33*9f3bdf3dSAdrien Destugues
34*9f3bdf3dSAdrien Destuguesberes allows multiple type codes and/or type casts per resource statement/data field, but we allow
35*9f3bdf3dSAdrien Destuguesonly one of each. Because we don't associate type codes with data (but only with the resource
36*9f3bdf3dSAdrien Destuguesitself or with individual message fields), we don't allow the shortcut notation that lets you put a
37*9f3bdf3dSAdrien Destuguestype code and cast inside one set of parentheses.
38*9f3bdf3dSAdrien Destugues
39*9f3bdf3dSAdrien DestuguesWe do not allow arrays to have named fields, nor do we allow messages (and archives) to have
40*9f3bdf3dSAdrien Destuguesunnamed fields. beres apparently treats all compound data the same, but we don't, because not all
41*9f3bdf3dSAdrien Destuguescompound data is the same.
42*9f3bdf3dSAdrien Destugues
43*9f3bdf3dSAdrien DestuguesWhen specifying array data, the "array" keyword is required. beres allows you to omit the array
44*9f3bdf3dSAdrien Destugueskeyword and just put the data between braces, but that conflicts with our handling of user-defined
45*9f3bdf3dSAdrien Destuguestypes.
46*9f3bdf3dSAdrien Destugues
47*9f3bdf3dSAdrien DestuguesField names in message resources may only be string literals. beres allows identifiers but it
48*9f3bdf3dSAdrien Destuguesconverts them to string literals anyway. Just like normal data, you may cast the field's data to a
49*9f3bdf3dSAdrien Destuguesdifferent type, but not to a different type code. Specifying a non-standard type code is fine, but
50*9f3bdf3dSAdrien Destuguesit goes in front of the type name. Just like beres, rc considers "array", "message", and "archive"
51*9f3bdf3dSAdrien Destuguesto be valid data type names, but "message" and "archive" cannot be followed by a "what" code
52*9f3bdf3dSAdrien Destugues(beres ignores that anyway). When you cast an archive to a message, we don't strip the "class"
53*9f3bdf3dSAdrien Destuguesfield (in fact, we don't perform any conversion).
54*9f3bdf3dSAdrien Destugues
55*9f3bdf3dSAdrien DestuguesWe allow users to define their own types. The built-in types from beres (point, rect, and rgb_color)
56*9f3bdf3dSAdrien Destuguesare re-implemented as such user-defined types. The syntax for these three built-ins should still be
57*9f3bdf3dSAdrien Destuguesbackwards compatible with old scripts.
58*9f3bdf3dSAdrien Destugues
59*9f3bdf3dSAdrien Destuguesberes automatically adds names for resources that are specified as "resource(R_Symbol)", unless the
60*9f3bdf3dSAdrien Destugues"explicit names only" option is set. We do that the other way around: we don't automatically add
61*9f3bdf3dSAdrien Destuguesnames unless the user sets the "auto names" option.
62*9f3bdf3dSAdrien Destugues
63*9f3bdf3dSAdrien DestuguesDifferences with deres
64*9f3bdf3dSAdrien Destugues======================
65*9f3bdf3dSAdrien Destugues
66*9f3bdf3dSAdrien DestuguesWe do not write the "generated at" time into the files.
67*9f3bdf3dSAdrien Destugues
68*9f3bdf3dSAdrien DestuguesType codes that cannot be represented as #'xxxx' are written as #num where num is a decimal number, not hexadecimal.
69*9f3bdf3dSAdrien Destugues
70*9f3bdf3dSAdrien DestuguesFloats and doubles have a bunch of extra zeroes.
71*9f3bdf3dSAdrien Destugues
72*9f3bdf3dSAdrien DestuguesHex numbers are always uppercase.
73*9f3bdf3dSAdrien Destugues
74*9f3bdf3dSAdrien DestuguesWe may render string literals somewhat differently.
75*9f3bdf3dSAdrien Destugues
76*9f3bdf3dSAdrien DestuguesWe only write a header file if the "auto names" option is set.
77*9f3bdf3dSAdrien Destugues
78