mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-09 04:59:31 -06:00
More changes to compile on macOS (incomplete)
This commit is contained in:
@@ -28,7 +28,7 @@ libpgf_la_SOURCES = \
|
||||
pgf/namespace.h
|
||||
|
||||
libpgf_la_LDFLAGS = -no-undefined
|
||||
libpgf_la_LIBADD = -lrt
|
||||
libpgf_la_LIBADD =
|
||||
libpgf_la_CXXFLAGS = -fno-rtti -std=c++11
|
||||
|
||||
bin_PROGRAMS =
|
||||
|
||||
@@ -123,7 +123,13 @@ struct PGF_INTERNAL_DECL PgfPGF {
|
||||
static void release(ref<PgfPGF> pgf);
|
||||
};
|
||||
|
||||
// extern PGF_INTERNAL_DECL
|
||||
// PgfText master;
|
||||
|
||||
extern PGF_INTERNAL_DECL
|
||||
PgfText master;
|
||||
size_t master_size;
|
||||
|
||||
extern PGF_INTERNAL_DECL
|
||||
char master_text[];
|
||||
|
||||
#endif
|
||||
|
||||
@@ -883,8 +883,16 @@ object PgfDB::malloc_internal(size_t bytes)
|
||||
throw pgf_systemerror(errno, filepath);
|
||||
}
|
||||
|
||||
// OSX mman and mman-win32 do not implement mremap or MREMAP_MAYMOVE
|
||||
#ifndef MREMAP_MAYMOVE
|
||||
if (munmap(ms, old_size) == -1)
|
||||
throw pgf_systemerror(errno);
|
||||
malloc_state* new_ms =
|
||||
(malloc_state*) mmap(0, new_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
|
||||
#else
|
||||
malloc_state* new_ms =
|
||||
(malloc_state*) mremap(ms, old_size, new_size, MREMAP_MAYMOVE);
|
||||
#endif
|
||||
if (new_ms == MAP_FAILED)
|
||||
throw pgf_systemerror(errno);
|
||||
|
||||
|
||||
@@ -256,7 +256,7 @@ void PgfExprParser::putc(uint32_t ucs)
|
||||
ucs < 0x10000 ? 3 :
|
||||
ucs < 0x200000 ? 4 :
|
||||
ucs < 0x4000000 ? 5 :
|
||||
6
|
||||
6
|
||||
);
|
||||
size_t len = token_value ? token_value->size : 0;
|
||||
|
||||
@@ -365,9 +365,10 @@ void PgfExprParser::token()
|
||||
}
|
||||
|
||||
switch (ch) {
|
||||
case EOF:
|
||||
token_tag = PGF_TOKEN_EOF;
|
||||
break;
|
||||
// TODO
|
||||
// case EOF:
|
||||
// token_tag = PGF_TOKEN_EOF;
|
||||
// break;
|
||||
case '(':
|
||||
ch = getc();
|
||||
token_tag = PGF_TOKEN_LPAR;
|
||||
@@ -615,7 +616,8 @@ PgfExpr PgfExprParser::parse_arg()
|
||||
return arg;
|
||||
}
|
||||
|
||||
PGF_INTERNAL PgfText wildcard = {size: 1, text: {'_',0}};
|
||||
// PGF_INTERNAL PgfText wildcard = {size: 1, text: {'_',0}};
|
||||
PGF_INTERNAL PgfText wildcard = {size: 1, text: {}}; // TODO
|
||||
|
||||
PgfBind *PgfExprParser::parse_bind(PgfBind *next)
|
||||
{
|
||||
@@ -826,7 +828,7 @@ PgfType PgfExprParser::parse_type()
|
||||
size_t n_start = n_hypos;
|
||||
|
||||
if ((token_tag == PGF_TOKEN_IDENT &&
|
||||
(lookahead(',') ||
|
||||
(lookahead(',') ||
|
||||
lookahead(':'))) ||
|
||||
(token_tag == PGF_TOKEN_LCURLY) ||
|
||||
(token_tag == PGF_TOKEN_WILD)) {
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
#include <sys/mman.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <pthread.h>
|
||||
|
||||
#include "pgf/data.h"
|
||||
|
||||
typedef struct {
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#include <fcntl.h>
|
||||
#include <math.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "data.h"
|
||||
#include "reader.h"
|
||||
#include "writer.h"
|
||||
@@ -28,8 +30,14 @@ pgf_exn_clear(PgfExn* err)
|
||||
err->msg = strdup(e.what()); \
|
||||
}
|
||||
|
||||
// PGF_INTERNAL
|
||||
// PgfText master = {size: 6, text: {}};
|
||||
|
||||
PGF_INTERNAL
|
||||
PgfText master = {size: 6, text: {'m','a','s','t','e','r',0}};
|
||||
size_t master_size = 6;
|
||||
|
||||
PGF_INTERNAL
|
||||
char master_text[] = {'m','a','s','t','e','r',0};
|
||||
|
||||
PGF_API
|
||||
PgfDB *pgf_read_pgf(const char* fpath,
|
||||
@@ -124,10 +132,14 @@ PgfDB *pgf_read_ngf(const char *fpath,
|
||||
PGF_API_BEGIN {
|
||||
db = new PgfDB(fpath, O_RDWR, 0);
|
||||
|
||||
PgfText *master = (PgfText *)alloca(sizeof(PgfText)+master_size+1);
|
||||
master->size = master_size;
|
||||
strcpy(master->text, master_text);
|
||||
|
||||
{
|
||||
DB_scope scope(db, WRITER_SCOPE);
|
||||
|
||||
ref<PgfPGF> pgf = PgfDB::get_revision(&master);
|
||||
ref<PgfPGF> pgf = PgfDB::get_revision(master);
|
||||
Node<PgfPGF>::add_value_ref(pgf);
|
||||
*revision = pgf.as_object();
|
||||
}
|
||||
@@ -159,7 +171,7 @@ PgfDB *pgf_new_ngf(PgfText *abstract_name,
|
||||
{
|
||||
DB_scope scope(db, WRITER_SCOPE);
|
||||
|
||||
ref<PgfPGF> pgf = PgfDB::malloc<PgfPGF>(master.size+1);
|
||||
ref<PgfPGF> pgf = PgfDB::malloc<PgfPGF>(master_size+1);
|
||||
pgf->ref_count = 1;
|
||||
pgf->major_version = PGF_MAJOR_VERSION;
|
||||
pgf->minor_version = PGF_MINOR_VERSION;
|
||||
@@ -171,7 +183,8 @@ PgfDB *pgf_new_ngf(PgfText *abstract_name,
|
||||
pgf->abstract.cats = 0;
|
||||
pgf->prev = 0;
|
||||
pgf->next = 0;
|
||||
memcpy(&pgf->name, &master, sizeof(PgfText)+master.size+1);
|
||||
pgf->name.size = master_size;
|
||||
memcpy(&pgf->name.text, master_text, master_size+1);
|
||||
PgfDB::set_revision(pgf);
|
||||
*revision = pgf.as_object();
|
||||
|
||||
@@ -269,7 +282,7 @@ void pgf_iter_categories(PgfDB *db, PgfRevision revision,
|
||||
PGF_API_BEGIN {
|
||||
DB_scope scope(db, READER_SCOPE);
|
||||
ref<PgfPGF> pgf = PgfDB::revision2pgf(revision);
|
||||
|
||||
|
||||
namespace_iter(pgf->abstract.cats, itor, err);
|
||||
} PGF_API_END
|
||||
}
|
||||
@@ -671,7 +684,7 @@ void pgf_create_function(PgfDB *db, PgfRevision revision,
|
||||
ref<PgfExprFun>::from_ptr((PgfExprFun*) &absfun->name);
|
||||
absfun->ep.expr = ref<PgfExprFun>::tagged(efun);
|
||||
memcpy(&absfun->name, name, sizeof(PgfText)+name->size+1);
|
||||
|
||||
|
||||
Namespace<PgfAbsFun> funs =
|
||||
namespace_insert(pgf->abstract.funs, absfun);
|
||||
namespace_release(pgf->abstract.funs);
|
||||
|
||||
@@ -430,7 +430,7 @@ void PgfReader::read_abstract(ref<PgfAbstr> abstract)
|
||||
|
||||
ref<PgfPGF> PgfReader::read_pgf()
|
||||
{
|
||||
ref<PgfPGF> pgf = PgfDB::malloc<PgfPGF>(master.size+1);
|
||||
ref<PgfPGF> pgf = PgfDB::malloc<PgfPGF>(master_size+1);
|
||||
|
||||
pgf->ref_count = 1;
|
||||
pgf->major_version = read_u16be();
|
||||
@@ -448,7 +448,8 @@ ref<PgfPGF> PgfReader::read_pgf()
|
||||
pgf->prev = 0;
|
||||
pgf->next = 0;
|
||||
|
||||
memcpy(&pgf->name, &master, sizeof(PgfText)+master.size+1);
|
||||
pgf->name.size = master_size;
|
||||
memcpy(&pgf->name.text, master_text, master_size+1);
|
||||
|
||||
return pgf;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user