mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-18 00:32:11 +01:00
Add a base.utility type
This commit is contained in:
1 parent
3ece6e0f1d
commit
92a8bc4641
21 files changed
+89
-1
No files matched your search
@@ -52,6 +52,11 @@
|
||||
typedef struct {
|
||||
} wuffs_base__empty_struct;
|
||||
|
||||
// wuffs_base__utility is a placeholder receiver type. It enables what Java
|
||||
// calls static methods, as opposed to regular methods.
|
||||
typedef struct {
|
||||
} wuffs_base__utility;
|
||||
|
||||
// --------
|
||||
|
||||
// A status code is either zero (OK), positive (a recoverable suspension or
|
||||
|
||||
@@ -19,7 +19,7 @@ package cgen
|
||||
const basePublicH = "" +
|
||||
"#ifndef WUFFS_BASE_PUBLIC_H\n#define WUFFS_BASE_PUBLIC_H\n\n// Copyright 2017 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#include <stdbool.h>\n#include <stdint.h>\n#include <string.h>\n\n// Wuffs assumes that:\n// - converting a uint32_t to a size_t will never overflow.\n// - converting a size_t to a uint64_t will never overflow.\n#if (__WORDSIZE != 32) && (__WORDSIZE != 64)\n#error \"Wuffs requires a word size of either 32 or 64 bits\"\n#endif\n\n// WUFFS_VERSION is the major.minor.patch version, " +
|
||||
"as per https://semver.org/,\n// as a uint64_t. The major number is the high 32 bits. The minor number is the\n// middle 16 bits. The patch number is the low 16 bits. The version extension\n// (such as \"\", \"beta\" or \"rc.1\") is part of the string representation (such as\n// \"1.2.3-beta\") but not the uint64_t representation.\n//\n// All three of major, minor and patch being zero means that this is a\n// work-in-progress version, not a release version, and has no backwards or\n// forwards compatibility guarantees.\n//\n// !! Some code generation programs can override WUFFS_VERSION.\n#define WUFFS_VERSION ((uint64_t)0)\n#define WUFFS_VERSION_MAJOR ((uint64_t)0)\n#define WUFFS_VERSION_MINOR ((uint64_t)0)\n#define WUFFS_VERSION_PATCH ((uint64_t)0)\n#define WUFFS_VERSION_EXTENSION \"\"\n#define WUFFS_VERSION_STRING \"0.0.0\"\n\n// wuffs_base__empty_struct is used when a Wuffs function returns an empty\n// struct. In C, if a function f returns void, you can't say \"x = f()\", but in\n// Wuffs, if a function g returns empty, you can say \"y = g(" +
|
||||
")\".\ntypedef struct {\n} wuffs_base__empty_struct;\n\n" +
|
||||
")\".\ntypedef struct {\n} wuffs_base__empty_struct;\n\n// wuffs_base__utility is a placeholder receiver type. It enables what Java\n// calls static methods, as opposed to regular methods.\ntypedef struct {\n} wuffs_base__utility;\n\n" +
|
||||
"" +
|
||||
"// --------\n\n// A status code is either zero (OK), positive (a recoverable suspension or\n// pause in processing) or negative (a non-recoverable error). Its bits:\n// - bit 31 (the sign bit) indicates unrecoverable-ness: an error.\n// - bits 30 .. 24 are a package-namespaced numeric code\n// - bits 23 .. 21 are reserved.\n// - bits 20 .. 0 are the packageid (a namespace) as a base38 value.\n//\n// Do not manipulate these bits directly; they are private implementation\n// details. Use methods such as wuffs_base__status__is_error instead.\ntypedef int32_t wuffs_base__status;\n\n// !! INSERT wuffs_base__status names.\n\nstatic inline bool wuffs_base__status__is_error(wuffs_base__status s) {\n return s < 0;\n}\n\nstatic inline bool wuffs_base__status__is_ok(wuffs_base__status s) {\n return s == 0;\n}\n\nstatic inline bool wuffs_base__status__is_suspension(wuffs_base__status s) {\n return s > 0;\n}\n\nconst char* wuffs_base__status__string(wuffs_base__status s);\n\n" +
|
||||
"" +
|
||||
|
||||
@@ -66,6 +66,11 @@
|
||||
typedef struct {
|
||||
} wuffs_base__empty_struct;
|
||||
|
||||
// wuffs_base__utility is a placeholder receiver type. It enables what Java
|
||||
// calls static methods, as opposed to regular methods.
|
||||
typedef struct {
|
||||
} wuffs_base__utility;
|
||||
|
||||
// --------
|
||||
|
||||
// A status code is either zero (OK), positive (a recoverable suspension or
|
||||
|
||||
@@ -55,6 +55,11 @@
|
||||
typedef struct {
|
||||
} wuffs_base__empty_struct;
|
||||
|
||||
// wuffs_base__utility is a placeholder receiver type. It enables what Java
|
||||
// calls static methods, as opposed to regular methods.
|
||||
typedef struct {
|
||||
} wuffs_base__utility;
|
||||
|
||||
// --------
|
||||
|
||||
// A status code is either zero (OK), positive (a recoverable suspension or
|
||||
|
||||
@@ -55,6 +55,11 @@
|
||||
typedef struct {
|
||||
} wuffs_base__empty_struct;
|
||||
|
||||
// wuffs_base__utility is a placeholder receiver type. It enables what Java
|
||||
// calls static methods, as opposed to regular methods.
|
||||
typedef struct {
|
||||
} wuffs_base__utility;
|
||||
|
||||
// --------
|
||||
|
||||
// A status code is either zero (OK), positive (a recoverable suspension or
|
||||
|
||||
@@ -55,6 +55,11 @@
|
||||
typedef struct {
|
||||
} wuffs_base__empty_struct;
|
||||
|
||||
// wuffs_base__utility is a placeholder receiver type. It enables what Java
|
||||
// calls static methods, as opposed to regular methods.
|
||||
typedef struct {
|
||||
} wuffs_base__utility;
|
||||
|
||||
// --------
|
||||
|
||||
// A status code is either zero (OK), positive (a recoverable suspension or
|
||||
|
||||
@@ -55,6 +55,11 @@
|
||||
typedef struct {
|
||||
} wuffs_base__empty_struct;
|
||||
|
||||
// wuffs_base__utility is a placeholder receiver type. It enables what Java
|
||||
// calls static methods, as opposed to regular methods.
|
||||
typedef struct {
|
||||
} wuffs_base__utility;
|
||||
|
||||
// --------
|
||||
|
||||
// A status code is either zero (OK), positive (a recoverable suspension or
|
||||
@@ -1414,6 +1419,7 @@ typedef struct {
|
||||
uint32_t f_uncompressed_wi;
|
||||
uint8_t f_uncompressed[4096];
|
||||
uint8_t f_palettes[2][1024];
|
||||
wuffs_base__utility f_util;
|
||||
wuffs_lzw__decoder f_lzw;
|
||||
|
||||
struct {
|
||||
|
||||
@@ -55,6 +55,11 @@
|
||||
typedef struct {
|
||||
} wuffs_base__empty_struct;
|
||||
|
||||
// wuffs_base__utility is a placeholder receiver type. It enables what Java
|
||||
// calls static methods, as opposed to regular methods.
|
||||
typedef struct {
|
||||
} wuffs_base__utility;
|
||||
|
||||
// --------
|
||||
|
||||
// A status code is either zero (OK), positive (a recoverable suspension or
|
||||
|
||||
@@ -55,6 +55,11 @@
|
||||
typedef struct {
|
||||
} wuffs_base__empty_struct;
|
||||
|
||||
// wuffs_base__utility is a placeholder receiver type. It enables what Java
|
||||
// calls static methods, as opposed to regular methods.
|
||||
typedef struct {
|
||||
} wuffs_base__utility;
|
||||
|
||||
// --------
|
||||
|
||||
// A status code is either zero (OK), positive (a recoverable suspension or
|
||||
|
||||
@@ -55,6 +55,11 @@
|
||||
typedef struct {
|
||||
} wuffs_base__empty_struct;
|
||||
|
||||
// wuffs_base__utility is a placeholder receiver type. It enables what Java
|
||||
// calls static methods, as opposed to regular methods.
|
||||
typedef struct {
|
||||
} wuffs_base__utility;
|
||||
|
||||
// --------
|
||||
|
||||
// A status code is either zero (OK), positive (a recoverable suspension or
|
||||
|
||||
@@ -55,6 +55,11 @@
|
||||
typedef struct {
|
||||
} wuffs_base__empty_struct;
|
||||
|
||||
// wuffs_base__utility is a placeholder receiver type. It enables what Java
|
||||
// calls static methods, as opposed to regular methods.
|
||||
typedef struct {
|
||||
} wuffs_base__utility;
|
||||
|
||||
// --------
|
||||
|
||||
// A status code is either zero (OK), positive (a recoverable suspension or
|
||||
|
||||
@@ -55,6 +55,11 @@
|
||||
typedef struct {
|
||||
} wuffs_base__empty_struct;
|
||||
|
||||
// wuffs_base__utility is a placeholder receiver type. It enables what Java
|
||||
// calls static methods, as opposed to regular methods.
|
||||
typedef struct {
|
||||
} wuffs_base__utility;
|
||||
|
||||
// --------
|
||||
|
||||
// A status code is either zero (OK), positive (a recoverable suspension or
|
||||
|
||||
@@ -55,6 +55,11 @@
|
||||
typedef struct {
|
||||
} wuffs_base__empty_struct;
|
||||
|
||||
// wuffs_base__utility is a placeholder receiver type. It enables what Java
|
||||
// calls static methods, as opposed to regular methods.
|
||||
typedef struct {
|
||||
} wuffs_base__utility;
|
||||
|
||||
// --------
|
||||
|
||||
// A status code is either zero (OK), positive (a recoverable suspension or
|
||||
|
||||
@@ -55,6 +55,11 @@
|
||||
typedef struct {
|
||||
} wuffs_base__empty_struct;
|
||||
|
||||
// wuffs_base__utility is a placeholder receiver type. It enables what Java
|
||||
// calls static methods, as opposed to regular methods.
|
||||
typedef struct {
|
||||
} wuffs_base__utility;
|
||||
|
||||
// --------
|
||||
|
||||
// A status code is either zero (OK), positive (a recoverable suspension or
|
||||
@@ -1414,6 +1419,7 @@ typedef struct {
|
||||
uint32_t f_uncompressed_wi;
|
||||
uint8_t f_uncompressed[4096];
|
||||
uint8_t f_palettes[2][1024];
|
||||
wuffs_base__utility f_util;
|
||||
wuffs_lzw__decoder f_lzw;
|
||||
|
||||
struct {
|
||||
|
||||
@@ -55,6 +55,11 @@
|
||||
typedef struct {
|
||||
} wuffs_base__empty_struct;
|
||||
|
||||
// wuffs_base__utility is a placeholder receiver type. It enables what Java
|
||||
// calls static methods, as opposed to regular methods.
|
||||
typedef struct {
|
||||
} wuffs_base__utility;
|
||||
|
||||
// --------
|
||||
|
||||
// A status code is either zero (OK), positive (a recoverable suspension or
|
||||
|
||||
@@ -55,6 +55,11 @@
|
||||
typedef struct {
|
||||
} wuffs_base__empty_struct;
|
||||
|
||||
// wuffs_base__utility is a placeholder receiver type. It enables what Java
|
||||
// calls static methods, as opposed to regular methods.
|
||||
typedef struct {
|
||||
} wuffs_base__utility;
|
||||
|
||||
// --------
|
||||
|
||||
// A status code is either zero (OK), positive (a recoverable suspension or
|
||||
|
||||
@@ -55,6 +55,11 @@
|
||||
typedef struct {
|
||||
} wuffs_base__empty_struct;
|
||||
|
||||
// wuffs_base__utility is a placeholder receiver type. It enables what Java
|
||||
// calls static methods, as opposed to regular methods.
|
||||
typedef struct {
|
||||
} wuffs_base__utility;
|
||||
|
||||
// --------
|
||||
|
||||
// A status code is either zero (OK), positive (a recoverable suspension or
|
||||
|
||||
@@ -79,6 +79,7 @@ var Types = []string{
|
||||
|
||||
"empty_struct",
|
||||
"bool",
|
||||
"utility",
|
||||
|
||||
"rect_ie_u32",
|
||||
"rect_ii_u32",
|
||||
|
||||
@@ -47,6 +47,7 @@ var (
|
||||
|
||||
typeExprEmptyStruct = a.NewTypeExpr(0, t.IDBase, t.IDEmptyStruct, nil, nil, nil)
|
||||
typeExprBool = a.NewTypeExpr(0, t.IDBase, t.IDBool, nil, nil, nil)
|
||||
typeExprUtility = a.NewTypeExpr(0, t.IDBase, t.IDUtility, nil, nil, nil)
|
||||
|
||||
typeExprRectIEU32 = a.NewTypeExpr(0, t.IDBase, t.IDRectIEU32, nil, nil, nil)
|
||||
typeExprRectIIU32 = a.NewTypeExpr(0, t.IDBase, t.IDRectIIU32, nil, nil, nil)
|
||||
@@ -72,6 +73,7 @@ var builtInTypeMap = typeMap{
|
||||
|
||||
t.IDEmptyStruct: typeExprEmptyStruct,
|
||||
t.IDBool: typeExprBool,
|
||||
t.IDUtility: typeExprUtility,
|
||||
|
||||
t.IDRectIEU32: typeExprRectIEU32,
|
||||
t.IDRectIIU32: typeExprRectIIU32,
|
||||
|
||||
@@ -397,6 +397,7 @@ const (
|
||||
|
||||
IDEmptyStruct = ID(0x100)
|
||||
IDBool = ID(0x101)
|
||||
IDUtility = ID(0x102)
|
||||
|
||||
IDRectIEU32 = ID(0x108)
|
||||
IDRectIIU32 = ID(0x109)
|
||||
@@ -624,6 +625,7 @@ var builtInsByID = [nBuiltInIDs]string{
|
||||
|
||||
IDEmptyStruct: "empty_struct",
|
||||
IDBool: "bool",
|
||||
IDUtility: "utility",
|
||||
|
||||
IDRectIEU32: "rect_ie_u32",
|
||||
IDRectIIU32: "rect_ii_u32",
|
||||
|
||||
@@ -97,6 +97,7 @@ pub struct decoder?(
|
||||
// palettes[0] and palettes[1] are the Global and Local Color Table.
|
||||
palettes array[2] array[4 * 256] base.u8,
|
||||
|
||||
util base.utility,
|
||||
lzw lzw.decoder,
|
||||
)
|
||||
|
||||
|
||||
Reference in new issue
Block a user