mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-18 00:32:11 +01:00
Implement INSERT wuffs_base__status__string data
This commit is contained in:
1 parent
35af4c4841
commit
2ac2424e77
4 files changed
+98
-5
No files matched your search
@@ -19,5 +19,6 @@
|
||||
// !! INSERT wuffs_base__status__string data.
|
||||
|
||||
const char* wuffs_base__status__string(wuffs_base__status s) {
|
||||
return "unknown status";
|
||||
uint16_t o = wuffs_base__status__string_offsets[(uint8_t)(s >> 24)];
|
||||
return o ? wuffs_base__status__string_data + o : "unknown status";
|
||||
}
|
||||
@@ -83,8 +83,11 @@ func Do(args []string) error {
|
||||
if err := expandBangBangInsert(&buf, baseImplC, map[string]func(*buffer) error{
|
||||
"// !! INSERT base-public.h.\n": insertBasePublicH,
|
||||
"// !! INSERT wuffs_base__status__string data.\n": func(b *buffer) error {
|
||||
// TODO.
|
||||
return nil
|
||||
messages := [256]string{}
|
||||
for _, z := range builtin.StatusList {
|
||||
messages[uint8(z.Value)] = z.Message
|
||||
}
|
||||
return genStatusStringData(b, "wuffs_base__", &messages)
|
||||
},
|
||||
}); err != nil {
|
||||
return nil, err
|
||||
@@ -234,6 +237,36 @@ func insertBasePublicH(buf *buffer) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func genStatusStringData(b *buffer, pkgPrefix string, ss *[256]string) error {
|
||||
data := []byte{0x00}
|
||||
offsets := [256]uint16{}
|
||||
for i, s := range ss {
|
||||
if s == "" {
|
||||
continue
|
||||
}
|
||||
if len(data) > 0xFFFF {
|
||||
return errors.New("status string messages are too long")
|
||||
}
|
||||
offsets[i] = uint16(len(data))
|
||||
data = append(data, s...)
|
||||
data = append(data, 0x00)
|
||||
}
|
||||
|
||||
b.printf("static const char %sstatus__string_data[] = {\n", pkgPrefix)
|
||||
for _, x := range data {
|
||||
b.printf("0x%02X,", x)
|
||||
}
|
||||
b.writes("};\n\n")
|
||||
|
||||
b.printf("static const uint16_t %sstatus__string_offsets[] = {\n", pkgPrefix)
|
||||
for _, x := range offsets {
|
||||
b.printf("0x%04X,", x)
|
||||
}
|
||||
b.writes("};\n\n")
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
type gen struct {
|
||||
PKGPREFIX string // e.g. "WUFFS_JPEG__"
|
||||
pkgPrefix string // e.g. "wuffs_jpeg__"
|
||||
|
||||
@@ -123,7 +123,7 @@ const basePrivateH = "" +
|
||||
""
|
||||
|
||||
const baseImplC = "" +
|
||||
"// Copyright 2018 The Wuffs Authors.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// https://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\n// !! INSERT base-public.h.\n\n// !! INSERT wuffs_base__status__string data.\n\nconst char* wuffs_base__status__string(wuffs_base__status s) {\n return \"unknown status\";\n}\n" +
|
||||
"// Copyright 2018 The Wuffs Authors.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// https://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\n// !! INSERT base-public.h.\n\n// !! INSERT wuffs_base__status__string data.\n\nconst char* wuffs_base__status__string(wuffs_base__status s) {\n uint16_t o = wuffs_base__status__string_offsets[(uint8_t)(s >> 24)];\n return o ? wuffs_base__status__string_data + o : \"unknown status\";\n}\n" +
|
||||
""
|
||||
|
||||
type template_args_short_read struct {
|
||||
|
||||
+60
-1
@@ -1265,6 +1265,65 @@ static inline wuffs_base__table_u8 wuffs_base__image_buffer__plane(
|
||||
|
||||
#endif // WUFFS_BASE_PUBLIC_H
|
||||
|
||||
static const char wuffs_base__status__string_data[] = {
|
||||
0x00, 0x6F, 0x6B, 0x00, 0x65, 0x6E, 0x64, 0x20, 0x6F, 0x66, 0x20, 0x64,
|
||||
0x61, 0x74, 0x61, 0x00, 0x73, 0x68, 0x6F, 0x72, 0x74, 0x20, 0x72, 0x65,
|
||||
0x61, 0x64, 0x00, 0x73, 0x68, 0x6F, 0x72, 0x74, 0x20, 0x77, 0x72, 0x69,
|
||||
0x74, 0x65, 0x00, 0x63, 0x6C, 0x6F, 0x73, 0x65, 0x64, 0x20, 0x66, 0x6F,
|
||||
0x72, 0x20, 0x77, 0x72, 0x69, 0x74, 0x65, 0x73, 0x00, 0x75, 0x6E, 0x65,
|
||||
0x78, 0x70, 0x65, 0x63, 0x74, 0x65, 0x64, 0x20, 0x45, 0x4F, 0x46, 0x00,
|
||||
0x69, 0x6E, 0x76, 0x61, 0x6C, 0x69, 0x64, 0x20, 0x49, 0x2F, 0x4F, 0x20,
|
||||
0x6F, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x00, 0x63, 0x61,
|
||||
0x6E, 0x6E, 0x6F, 0x74, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6E, 0x20,
|
||||
0x61, 0x20, 0x73, 0x75, 0x73, 0x70, 0x65, 0x6E, 0x73, 0x69, 0x6F, 0x6E,
|
||||
0x00, 0x69, 0x6E, 0x76, 0x61, 0x6C, 0x69, 0x64, 0x20, 0x63, 0x61, 0x6C,
|
||||
0x6C, 0x20, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6E, 0x63, 0x65, 0x00, 0x63,
|
||||
0x68, 0x65, 0x63, 0x6B, 0x5F, 0x77, 0x75, 0x66, 0x66, 0x73, 0x5F, 0x76,
|
||||
0x65, 0x72, 0x73, 0x69, 0x6F, 0x6E, 0x20, 0x63, 0x61, 0x6C, 0x6C, 0x65,
|
||||
0x64, 0x20, 0x74, 0x77, 0x69, 0x63, 0x65, 0x00, 0x63, 0x68, 0x65, 0x63,
|
||||
0x6B, 0x5F, 0x77, 0x75, 0x66, 0x66, 0x73, 0x5F, 0x76, 0x65, 0x72, 0x73,
|
||||
0x69, 0x6F, 0x6E, 0x20, 0x6E, 0x6F, 0x74, 0x20, 0x63, 0x61, 0x6C, 0x6C,
|
||||
0x65, 0x64, 0x00, 0x62, 0x61, 0x64, 0x20, 0x61, 0x72, 0x67, 0x75, 0x6D,
|
||||
0x65, 0x6E, 0x74, 0x00, 0x62, 0x61, 0x64, 0x20, 0x72, 0x65, 0x63, 0x65,
|
||||
0x69, 0x76, 0x65, 0x72, 0x00, 0x62, 0x61, 0x64, 0x20, 0x73, 0x69, 0x7A,
|
||||
0x65, 0x6F, 0x66, 0x20, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x72,
|
||||
0x00, 0x62, 0x61, 0x64, 0x20, 0x77, 0x75, 0x66, 0x66, 0x73, 0x20, 0x76,
|
||||
0x65, 0x72, 0x73, 0x69, 0x6F, 0x6E, 0x00,
|
||||
};
|
||||
|
||||
static const uint16_t wuffs_base__status__string_offsets[] = {
|
||||
0x0001, 0x0004, 0x0010, 0x001B, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||
0x0000, 0x0000, 0x0000, 0x0027, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||
0x0039, 0x0048, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x005E,
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0079, 0x008F, 0x00B0, 0x0000, 0x0000,
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||
0x00CF, 0x00DC, 0x00E9, 0x00FD,
|
||||
};
|
||||
|
||||
const char* wuffs_base__status__string(wuffs_base__status s) {
|
||||
return "unknown status";
|
||||
uint16_t o = wuffs_base__status__string_offsets[(uint8_t)(s >> 24)];
|
||||
return o ? wuffs_base__status__string_data + o : "unknown status";
|
||||
}
|
||||
Reference in new issue
Block a user