File: constants.md

package info (click to toggle)
android-platform-system-tools-aidl 1%3A10.0.0%2Br36-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 1,848 kB
  • sloc: cpp: 19,674; java: 972; yacc: 377; python: 160; lex: 115; xml: 19; sh: 18; makefile: 18
file content (35 lines) | stat: -rw-r--r-- 816 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# Defining constants as part of an interface

AIDL has been enhanced to support defining integer and string constants
as part of an interface.

## Integer constants

```
interface IMyInterface {
    const int CONST_A = 1;
    const int CONST_B = 2;
    const int CONST_C = 3;
    ...
}
```

These map to appropriate 32 bit integer class constants in Java and C++ (e.g.
`IMyInterface.CONST_A` and `IMyInterface::CONST_A` respectively).

## String constants

```
interface IMyInterface {
    const String CONST_A = "foo";
    const String CONST_B = "bar";
    ...
}
```

These map to class level String constants in Java, and static getter
functions that return a const android::String16& in C++.

The constants are limited to contain printable ASCII characters < 0x10
and without backspaces (i.e. no '\' character).