Make mark a method, not a keyword.

This commit is contained in:
Nigel Tao committed 2017-10-26 12:31:27 +11:00
1 parent 36f5ae9bf4
commit 474a0d2ed7
11 files changed
+89 -17

No files matched your search

+21 -1
View File
@@ -344,6 +344,12 @@ puffs_flate__status puffs_flate__zlib_decoder__decode(
// See the License for the specific language governing permissions and
// limitations under the License.
// puffs_base__empty_struct is used when a Puffs function returns an empty
// struct. In C, if a function f returns void, you can't say "x = f()", but in
// Puffs, if a function g returns empty, you can say "y = g()".
typedef struct {
} puffs_base__empty_struct;
#define PUFFS_BASE__IGNORE_POTENTIALLY_UNUSED_VARIABLE(x) (void)(x)
// PUFFS_BASE__MAGIC is a magic number to check that initializers are called.
@@ -592,6 +598,20 @@ static inline uint32_t puffs_base__writer1__copy_from_slice32(
return n;
}
static inline puffs_base__empty_struct puffs_base__reader1__mark(
puffs_base__reader1* r,
uint8_t* m) {
r->private_impl.mark = m;
return ((puffs_base__empty_struct){});
}
static inline puffs_base__empty_struct puffs_base__writer1__mark(
puffs_base__writer1* w,
uint8_t* m) {
w->private_impl.mark = m;
return ((puffs_base__empty_struct){});
}
#endif // PUFFS_BASE_IMPL_H
// ---------------- Status Codes Implementations
@@ -842,7 +862,7 @@ puffs_flate__status puffs_flate__flate_decoder__decode(
PUFFS_BASE__COROUTINE_SUSPENSION_POINT(0);
while (true) {
a_dst.private_impl.mark = b_wptr_dst;
puffs_base__writer1__mark(&a_dst, b_wptr_dst);
PUFFS_BASE__COROUTINE_SUSPENSION_POINT(1);
if (a_dst.buf) {
size_t n = b_wptr_dst - (a_dst.buf->ptr + a_dst.buf->wi);
+20
View File
@@ -290,6 +290,12 @@ puffs_gif__status puffs_gif__lzw_decoder__decode(puffs_gif__lzw_decoder* self,
// See the License for the specific language governing permissions and
// limitations under the License.
// puffs_base__empty_struct is used when a Puffs function returns an empty
// struct. In C, if a function f returns void, you can't say "x = f()", but in
// Puffs, if a function g returns empty, you can say "y = g()".
typedef struct {
} puffs_base__empty_struct;
#define PUFFS_BASE__IGNORE_POTENTIALLY_UNUSED_VARIABLE(x) (void)(x)
// PUFFS_BASE__MAGIC is a magic number to check that initializers are called.
@@ -538,6 +544,20 @@ static inline uint32_t puffs_base__writer1__copy_from_slice32(
return n;
}
static inline puffs_base__empty_struct puffs_base__reader1__mark(
puffs_base__reader1* r,
uint8_t* m) {
r->private_impl.mark = m;
return ((puffs_base__empty_struct){});
}
static inline puffs_base__empty_struct puffs_base__writer1__mark(
puffs_base__writer1* w,
uint8_t* m) {
w->private_impl.mark = m;
return ((puffs_base__empty_struct){});
}
#endif // PUFFS_BASE_IMPL_H
// ---------------- Status Codes Implementations