Fix the "for new syntax" FIXME.

Empty structs are now (correctly) invalid. The hack of using an empty
struct to represent a handle returned from a builtin has been unnecessary
since opaque structs were implemented: now a pointer to an opaque struct
can be used. This is mostly safe as handles are aways negative and thus
attempting to dereference such a pointer should result in a VM error. It
will be even safer once const is implemented and the pointers can be made
constant (eg, typedef struct handle * const handle;)
This commit is contained in:
Bill Currie 2012-12-18 15:54:30 +09:00
parent 3e94869f1e
commit 4868a245b3
6 changed files with 10 additions and 10 deletions

View file

@ -1,8 +1,8 @@
#ifndef __ruamoko_Set_h
#define __ruamoko_Set_h
typedef struct set_s {} set_t;
typedef struct set_iter_s {} set_iter_t;
typedef struct set_s *set_t;
typedef struct set_iter_s *set_iter_t;
@extern void set_del_iter (set_iter_t *set_iter);
@extern unsigned set_iter_element (set_iter_t *set_iter);

View file

@ -1,7 +1,6 @@
#ifndef __ruamoko_hash_h
#define __ruamoko_hash_h
struct _hashtab_t {};
typedef struct _hashtab_t *hashtab_t;
@extern hashtab_t Hash_NewTable (int size, string gk (void *ele, void *data), void f (void *ele, void *data), void *ud);

View file

@ -3,9 +3,7 @@
#include "qfile.h"
struct plitem_s {int dummy;};
#define PL_TEST(item) (item.dummy)
typedef struct plitem_s plitem_t;
typedef struct plitem_s *plitem_t;
typedef enum {QFDictionary, QFArray, QFBinary, QFString} pltype_t; // possible types
@extern plitem_t PL_GetFromFile (QFile file);

View file

@ -1,7 +1,6 @@
#ifndef __ruamoko_qfile_h
#define __ruamoko_qfile_h
struct _qfile_t {};
typedef struct _qfile_t *QFile;
@extern int Qrename (string old, string new);

View file

@ -27,7 +27,7 @@
local string classname = nil;
local id class;
if (!PL_TEST (item))
if (!item)
return nil;
switch (PL_Type (item)) {
case QFDictionary:

View file

@ -566,8 +566,7 @@ struct_specifier
;
struct_defs
: /* empty */ //FIXME for new syntax
| struct_defs struct_def ';'
: struct_def_list ';'
| DEFS '(' identifier ')'
{
$3 = check_undefined ($3);
@ -583,6 +582,11 @@ struct_defs
}
;
struct_def_list
: struct_def
| struct_def_list ';' struct_def
;
struct_def
: type struct_decl_list
| type