mirror of
git://git.psyced.org/git/psyclpc
synced 2024-08-15 03:20:16 +00:00
glue to enable optional psyc parsers for each lpc object
This commit is contained in:
parent
394af40eb0
commit
51fea526ac
6 changed files with 40 additions and 9 deletions
|
@ -522,7 +522,7 @@ simulate.o : ../mudlib/sys/rtlimits.h ../mudlib/sys/regexp.h \
|
|||
mapping.h main.h lex.h heartbeat.h gcollect.h filestat.h ed.h comm.h \
|
||||
closure.h call_out.h backend.h array.h actions.h simulate.h my-alloca.h \
|
||||
typedefs.h driver.h interpret.h hash.h exec.h ptrtable.h bytecode.h \
|
||||
port.h config.h hosts/unix.h hosts/be/be.h machine.h
|
||||
port.h config.h hosts/unix.h hosts/be/be.h machine.h pkg-psyc.o
|
||||
|
||||
sprintf.o : xalloc.h swap.h svalue.h structs.h stdstrings.h simul_efun.h \
|
||||
simulate.h sent.h random.h ptrtable.h object.h mstrings.h mapping.h \
|
||||
|
|
|
@ -29,7 +29,6 @@
|
|||
# include <fcntl.h>
|
||||
|
||||
# include <psyc.h>
|
||||
# include <psyc/parser.h>
|
||||
# include <psyc/render.h>
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
@ -127,7 +126,7 @@ f_psyc_parse (svalue_t *sp) {
|
|||
}
|
||||
else if (sp->type == T_STRING) {
|
||||
printf("\npsyc_parse got a %d bytes long string...\n", mstrsize(sp->u.str));
|
||||
psyc_nextParseBuffer(&state, psyc_newString(get_txt(sp->u.str),
|
||||
psyc_setParseBuffer(&state, psyc_newString(get_txt(sp->u.str),
|
||||
mstrsize(sp->u.str)));
|
||||
}
|
||||
|
||||
|
@ -176,7 +175,7 @@ f_psyc_parse (svalue_t *sp) {
|
|||
{
|
||||
write(1, ">>> LIST START\n", 15);
|
||||
psyc_initParseListState(&listState);
|
||||
psyc_nextParseListBuffer(&listState, value);
|
||||
psyc_setParseListBuffer(&listState, value);
|
||||
while ((ret = psyc_parseList(&listState, &name, &value, &elem)))
|
||||
{
|
||||
switch (ret)
|
||||
|
|
|
@ -1,10 +1,20 @@
|
|||
#ifdef USE_PSYC
|
||||
|
||||
/* pkg-psyc takes and produces PSYC packets in form
|
||||
* of an array of mapping, mapping, string and string
|
||||
* or int* where necessary.
|
||||
*/
|
||||
|
||||
#define PSYC_ROUTING 0
|
||||
#define PSYC_ENTITY 1
|
||||
#define PSYC_METHOD 2
|
||||
#define PSYC_BODY 3
|
||||
# define PSYC_ROUTING 0
|
||||
# define PSYC_ENTITY 1
|
||||
# define PSYC_METHOD 2
|
||||
# define PSYC_BODY 3
|
||||
|
||||
# include <psyc/parser.h>
|
||||
|
||||
static inline void
|
||||
psyc_free_parser (psycParseState *ps) {
|
||||
/* if (ps) xfree((void *) ps); */
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -43,6 +43,10 @@
|
|||
#include "driver.h"
|
||||
#include "typedefs.h"
|
||||
|
||||
#ifdef USE_PSYC
|
||||
# include <psyc/parser.h>
|
||||
#endif
|
||||
|
||||
enum sent_type_e {
|
||||
SENT_PLAIN = 0 /* Normal action */
|
||||
, SENT_SHORT_VERB /* Action with abbreviatable verb */
|
||||
|
@ -127,6 +131,9 @@ struct shadow_s
|
|||
ed_buffer_t *ed_buffer; /* the editor buffer, if needed */
|
||||
#endif
|
||||
interactive_t *ip; /* the information for interactive objects */
|
||||
#ifdef USE_PSYC
|
||||
psycParseState *psyc_parser; /* in case this objects parses PSYC data */
|
||||
#endif
|
||||
};
|
||||
|
||||
/* --- Macros --- */
|
||||
|
@ -134,6 +141,7 @@ struct shadow_s
|
|||
#define O_GET_SHADOW(ob) ((shadow_t *)(ob)->sent)
|
||||
#define O_GET_INTERACTIVE(ob) (O_GET_SHADOW(ob)->ip)
|
||||
#define O_GET_EDBUFFER(ob) (O_GET_SHADOW(ob)->ed_buffer)
|
||||
#define O_GET_PSYC_PARSER(ob) (O_GET_SHADOW(ob)->psyc_parser)
|
||||
|
||||
/* Expand to an expression suitable to query or set the
|
||||
* indicated attribute. No checks are performed.
|
||||
|
|
|
@ -58,6 +58,9 @@
|
|||
#ifdef USE_SQLITE
|
||||
#include "pkg-sqlite.h"
|
||||
#endif
|
||||
#ifdef USE_PSYC
|
||||
#include "pkg-psyc.h"
|
||||
#endif
|
||||
#include "prolang.h"
|
||||
#include "sent.h"
|
||||
#include "simul_efun.h"
|
||||
|
@ -2698,6 +2701,11 @@ destruct (object_t *ob)
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef USE_PSYC
|
||||
if (shadow_sent->psyc_parser)
|
||||
psyc_free_parser(shadow_sent->psyc_parser);
|
||||
#endif
|
||||
|
||||
#ifdef USE_SHADOWING
|
||||
/* The chain of shadows is a double linked list. Take care to update
|
||||
* it correctly.
|
||||
|
@ -3173,6 +3181,9 @@ new_shadow_sent(void)
|
|||
#endif
|
||||
#ifdef USE_BUILTIN_EDITOR
|
||||
p->ed_buffer = NULL;
|
||||
#endif
|
||||
#ifdef USE_PSYC
|
||||
p->psyc_parser = NULL;
|
||||
#endif
|
||||
p->ip = NULL;
|
||||
return p;
|
||||
|
@ -3215,6 +3226,9 @@ check_shadow_sent (object_t *ob)
|
|||
#ifdef USE_BUILTIN_EDITOR
|
||||
&& !sh->ed_buffer
|
||||
#endif
|
||||
#ifdef USE_PSYC
|
||||
&& !sh->psyc_parser
|
||||
#endif
|
||||
#ifdef USE_SHADOWING
|
||||
&& !sh->shadowing
|
||||
&& !sh->shadowed_by
|
||||
|
|
|
@ -17,7 +17,7 @@ version_longtype="stable"
|
|||
# A timestamp, to be used by bumpversion and other scripts.
|
||||
# It can be used, for example, to 'touch' this file on every build, thus
|
||||
# forcing revision control systems to add it on every checkin automatically.
|
||||
version_stamp="Fri May 6 21:14:39 CEST 2011"
|
||||
version_stamp="Fri May 6 22:13:45 CEST 2011"
|
||||
|
||||
# Okay, LDMUD is using 3.x.x so to avoid conflicts let's just use 4.x.x
|
||||
version_major=4
|
||||
|
|
Loading…
Reference in a new issue