added missing files again
This commit is contained in:
parent
d012ea1b01
commit
80fcdc3162
10
qse/lib/scm/Makefile.am
Normal file
10
qse/lib/scm/Makefile.am
Normal file
@ -0,0 +1,10 @@
|
||||
|
||||
AUTOMAKE_OPTIONS = nostdinc
|
||||
|
||||
AM_CPPFLAGS = -I$(top_srcdir)/include
|
||||
|
||||
lib_LTLIBRARIES = libqsescm.la
|
||||
|
||||
libqsescm_la_SOURCES = scm.h scm.c err.c
|
||||
libqsescm_la_LDFLAGS = -L../cmn -version-info 1:0:0 -no-undefined
|
||||
libqsescm_la_LIBADD = -lqsecmn
|
551
qse/lib/scm/Makefile.in
Normal file
551
qse/lib/scm/Makefile.in
Normal file
@ -0,0 +1,551 @@
|
||||
# Makefile.in generated by automake 1.11.1 from Makefile.am.
|
||||
# @configure_input@
|
||||
|
||||
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
|
||||
# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
|
||||
# Inc.
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
|
||||
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE.
|
||||
|
||||
@SET_MAKE@
|
||||
|
||||
VPATH = @srcdir@
|
||||
pkgdatadir = $(datadir)/@PACKAGE@
|
||||
pkgincludedir = $(includedir)/@PACKAGE@
|
||||
pkglibdir = $(libdir)/@PACKAGE@
|
||||
pkglibexecdir = $(libexecdir)/@PACKAGE@
|
||||
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
|
||||
install_sh_DATA = $(install_sh) -c -m 644
|
||||
install_sh_PROGRAM = $(install_sh) -c
|
||||
install_sh_SCRIPT = $(install_sh) -c
|
||||
INSTALL_HEADER = $(INSTALL_DATA)
|
||||
transform = $(program_transform_name)
|
||||
NORMAL_INSTALL = :
|
||||
PRE_INSTALL = :
|
||||
POST_INSTALL = :
|
||||
NORMAL_UNINSTALL = :
|
||||
PRE_UNINSTALL = :
|
||||
POST_UNINSTALL = :
|
||||
build_triplet = @build@
|
||||
host_triplet = @host@
|
||||
subdir = lib/scm
|
||||
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
|
||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
am__aclocal_m4_deps = $(top_srcdir)/ac/m4/libtool.m4 \
|
||||
$(top_srcdir)/ac/m4/ltoptions.m4 \
|
||||
$(top_srcdir)/ac/m4/ltsugar.m4 \
|
||||
$(top_srcdir)/ac/m4/ltversion.m4 \
|
||||
$(top_srcdir)/ac/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac
|
||||
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
|
||||
$(ACLOCAL_M4)
|
||||
mkinstalldirs = $(install_sh) -d
|
||||
CONFIG_HEADER = $(top_builddir)/include/qse/config.h
|
||||
CONFIG_CLEAN_FILES =
|
||||
CONFIG_CLEAN_VPATH_FILES =
|
||||
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
|
||||
am__vpath_adj = case $$p in \
|
||||
$(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
|
||||
*) f=$$p;; \
|
||||
esac;
|
||||
am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
|
||||
am__install_max = 40
|
||||
am__nobase_strip_setup = \
|
||||
srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
|
||||
am__nobase_strip = \
|
||||
for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
|
||||
am__nobase_list = $(am__nobase_strip_setup); \
|
||||
for p in $$list; do echo "$$p $$p"; done | \
|
||||
sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
|
||||
$(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
|
||||
if (++n[$$2] == $(am__install_max)) \
|
||||
{ print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
|
||||
END { for (dir in files) print dir, files[dir] }'
|
||||
am__base_list = \
|
||||
sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
|
||||
sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
|
||||
am__installdirs = "$(DESTDIR)$(libdir)"
|
||||
LTLIBRARIES = $(lib_LTLIBRARIES)
|
||||
libqsescm_la_DEPENDENCIES =
|
||||
am_libqsescm_la_OBJECTS = scm.lo err.lo
|
||||
libqsescm_la_OBJECTS = $(am_libqsescm_la_OBJECTS)
|
||||
libqsescm_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
|
||||
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
|
||||
$(libqsescm_la_LDFLAGS) $(LDFLAGS) -o $@
|
||||
DEFAULT_INCLUDES =
|
||||
depcomp = $(SHELL) $(top_srcdir)/ac/au/depcomp
|
||||
am__depfiles_maybe = depfiles
|
||||
am__mv = mv -f
|
||||
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
|
||||
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
||||
LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
|
||||
--mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
|
||||
$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
||||
CCLD = $(CC)
|
||||
LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
|
||||
--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
|
||||
$(LDFLAGS) -o $@
|
||||
SOURCES = $(libqsescm_la_SOURCES)
|
||||
DIST_SOURCES = $(libqsescm_la_SOURCES)
|
||||
ETAGS = etags
|
||||
CTAGS = ctags
|
||||
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
||||
ACLOCAL = @ACLOCAL@
|
||||
AMTAR = @AMTAR@
|
||||
AR = @AR@
|
||||
AUTOCONF = @AUTOCONF@
|
||||
AUTOHEADER = @AUTOHEADER@
|
||||
AUTOMAKE = @AUTOMAKE@
|
||||
AWK = @AWK@
|
||||
BUILD_MODE = @BUILD_MODE@
|
||||
CC = @CC@
|
||||
CCDEPMODE = @CCDEPMODE@
|
||||
CFLAGS = @CFLAGS@
|
||||
CHAR_MODE = @CHAR_MODE@
|
||||
CPP = @CPP@
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
CXX = @CXX@
|
||||
CXXCPP = @CXXCPP@
|
||||
CXXDEPMODE = @CXXDEPMODE@
|
||||
CXXFLAGS = @CXXFLAGS@
|
||||
CYGPATH_W = @CYGPATH_W@
|
||||
DEFS = @DEFS@
|
||||
DEPDIR = @DEPDIR@
|
||||
DSYMUTIL = @DSYMUTIL@
|
||||
DUMPBIN = @DUMPBIN@
|
||||
ECHO_C = @ECHO_C@
|
||||
ECHO_N = @ECHO_N@
|
||||
ECHO_T = @ECHO_T@
|
||||
EGREP = @EGREP@
|
||||
EXEEXT = @EXEEXT@
|
||||
FGREP = @FGREP@
|
||||
GREP = @GREP@
|
||||
HAVE_CXX = @HAVE_CXX@
|
||||
HAVE_OBJC = @HAVE_OBJC@
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
|
||||
LD = @LD@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
LIBM = @LIBM@
|
||||
LIBOBJS = @LIBOBJS@
|
||||
LIBS = @LIBS@
|
||||
LIBTOOL = @LIBTOOL@
|
||||
LIBTOOL_DEPS = @LIBTOOL_DEPS@
|
||||
LIPO = @LIPO@
|
||||
LN_S = @LN_S@
|
||||
LTLIBOBJS = @LTLIBOBJS@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
MKDIR_P = @MKDIR_P@
|
||||
NM = @NM@
|
||||
NMEDIT = @NMEDIT@
|
||||
OBJC = @OBJC@
|
||||
OBJCDEPMODE = @OBJCDEPMODE@
|
||||
OBJCFLAGS = @OBJCFLAGS@
|
||||
OBJDUMP = @OBJDUMP@
|
||||
OBJEXT = @OBJEXT@
|
||||
OTOOL = @OTOOL@
|
||||
OTOOL64 = @OTOOL64@
|
||||
PACKAGE = @PACKAGE@
|
||||
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
|
||||
PACKAGE_NAME = @PACKAGE_NAME@
|
||||
PACKAGE_STRING = @PACKAGE_STRING@
|
||||
PACKAGE_TARNAME = @PACKAGE_TARNAME@
|
||||
PACKAGE_URL = @PACKAGE_URL@
|
||||
PACKAGE_VERSION = @PACKAGE_VERSION@
|
||||
PATH_SEPARATOR = @PATH_SEPARATOR@
|
||||
QSE_PROJECT_AUTHOR = @QSE_PROJECT_AUTHOR@
|
||||
QSE_PROJECT_URL = @QSE_PROJECT_URL@
|
||||
QSE_SIZEOF_CHAR = @QSE_SIZEOF_CHAR@
|
||||
QSE_SIZEOF_DOUBLE = @QSE_SIZEOF_DOUBLE@
|
||||
QSE_SIZEOF_FLOAT = @QSE_SIZEOF_FLOAT@
|
||||
QSE_SIZEOF_INT = @QSE_SIZEOF_INT@
|
||||
QSE_SIZEOF_LONG = @QSE_SIZEOF_LONG@
|
||||
QSE_SIZEOF_LONG_DOUBLE = @QSE_SIZEOF_LONG_DOUBLE@
|
||||
QSE_SIZEOF_LONG_LONG = @QSE_SIZEOF_LONG_LONG@
|
||||
QSE_SIZEOF_SHORT = @QSE_SIZEOF_SHORT@
|
||||
QSE_SIZEOF_VOID_P = @QSE_SIZEOF_VOID_P@
|
||||
QSE_SIZEOF_WCHAR_T = @QSE_SIZEOF_WCHAR_T@
|
||||
RANLIB = @RANLIB@
|
||||
RM = @RM@
|
||||
SED = @SED@
|
||||
SET_MAKE = @SET_MAKE@
|
||||
SHELL = @SHELL@
|
||||
STRIP = @STRIP@
|
||||
VERSION = @VERSION@
|
||||
abs_builddir = @abs_builddir@
|
||||
abs_srcdir = @abs_srcdir@
|
||||
abs_top_builddir = @abs_top_builddir@
|
||||
abs_top_srcdir = @abs_top_srcdir@
|
||||
ac_ct_CC = @ac_ct_CC@
|
||||
ac_ct_CXX = @ac_ct_CXX@
|
||||
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
|
||||
ac_ct_OBJC = @ac_ct_OBJC@
|
||||
am__include = @am__include@
|
||||
am__leading_dot = @am__leading_dot@
|
||||
am__quote = @am__quote@
|
||||
am__tar = @am__tar@
|
||||
am__untar = @am__untar@
|
||||
bindir = @bindir@
|
||||
build = @build@
|
||||
build_alias = @build_alias@
|
||||
build_cpu = @build_cpu@
|
||||
build_os = @build_os@
|
||||
build_vendor = @build_vendor@
|
||||
builddir = @builddir@
|
||||
datadir = @datadir@
|
||||
datarootdir = @datarootdir@
|
||||
docdir = @docdir@
|
||||
dvidir = @dvidir@
|
||||
exec_prefix = @exec_prefix@
|
||||
host = @host@
|
||||
host_alias = @host_alias@
|
||||
host_cpu = @host_cpu@
|
||||
host_os = @host_os@
|
||||
host_vendor = @host_vendor@
|
||||
htmldir = @htmldir@
|
||||
includedir = @includedir@
|
||||
infodir = @infodir@
|
||||
install_sh = @install_sh@
|
||||
libdir = @libdir@
|
||||
libexecdir = @libexecdir@
|
||||
localedir = @localedir@
|
||||
localstatedir = @localstatedir@
|
||||
lt_ECHO = @lt_ECHO@
|
||||
mandir = @mandir@
|
||||
mkdir_p = @mkdir_p@
|
||||
oldincludedir = @oldincludedir@
|
||||
pdfdir = @pdfdir@
|
||||
prefix = @prefix@
|
||||
program_transform_name = @program_transform_name@
|
||||
psdir = @psdir@
|
||||
sbindir = @sbindir@
|
||||
sharedstatedir = @sharedstatedir@
|
||||
srcdir = @srcdir@
|
||||
sysconfdir = @sysconfdir@
|
||||
target_alias = @target_alias@
|
||||
top_build_prefix = @top_build_prefix@
|
||||
top_builddir = @top_builddir@
|
||||
top_srcdir = @top_srcdir@
|
||||
AUTOMAKE_OPTIONS = nostdinc
|
||||
AM_CPPFLAGS = -I$(top_srcdir)/include
|
||||
lib_LTLIBRARIES = libqsescm.la
|
||||
libqsescm_la_SOURCES = scm.h scm.c err.c
|
||||
libqsescm_la_LDFLAGS = -L../cmn -version-info 1:0:0 -no-undefined
|
||||
libqsescm_la_LIBADD = -lqsecmn
|
||||
all: all-am
|
||||
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .c .lo .o .obj
|
||||
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
|
||||
@for dep in $?; do \
|
||||
case '$(am__configure_deps)' in \
|
||||
*$$dep*) \
|
||||
( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
|
||||
&& { if test -f $@; then exit 0; else break; fi; }; \
|
||||
exit 1;; \
|
||||
esac; \
|
||||
done; \
|
||||
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign lib/scm/Makefile'; \
|
||||
$(am__cd) $(top_srcdir) && \
|
||||
$(AUTOMAKE) --foreign lib/scm/Makefile
|
||||
.PRECIOUS: Makefile
|
||||
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
|
||||
@case '$?' in \
|
||||
*config.status*) \
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
|
||||
*) \
|
||||
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
|
||||
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
|
||||
esac;
|
||||
|
||||
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
|
||||
|
||||
$(top_srcdir)/configure: $(am__configure_deps)
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
|
||||
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
|
||||
$(am__aclocal_m4_deps):
|
||||
install-libLTLIBRARIES: $(lib_LTLIBRARIES)
|
||||
@$(NORMAL_INSTALL)
|
||||
test -z "$(libdir)" || $(MKDIR_P) "$(DESTDIR)$(libdir)"
|
||||
@list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
|
||||
list2=; for p in $$list; do \
|
||||
if test -f $$p; then \
|
||||
list2="$$list2 $$p"; \
|
||||
else :; fi; \
|
||||
done; \
|
||||
test -z "$$list2" || { \
|
||||
echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \
|
||||
$(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \
|
||||
}
|
||||
|
||||
uninstall-libLTLIBRARIES:
|
||||
@$(NORMAL_UNINSTALL)
|
||||
@list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
|
||||
for p in $$list; do \
|
||||
$(am__strip_dir) \
|
||||
echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \
|
||||
$(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \
|
||||
done
|
||||
|
||||
clean-libLTLIBRARIES:
|
||||
-test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
|
||||
@list='$(lib_LTLIBRARIES)'; for p in $$list; do \
|
||||
dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
|
||||
test "$$dir" != "$$p" || dir=.; \
|
||||
echo "rm -f \"$${dir}/so_locations\""; \
|
||||
rm -f "$${dir}/so_locations"; \
|
||||
done
|
||||
libqsescm.la: $(libqsescm_la_OBJECTS) $(libqsescm_la_DEPENDENCIES)
|
||||
$(libqsescm_la_LINK) -rpath $(libdir) $(libqsescm_la_OBJECTS) $(libqsescm_la_LIBADD) $(LIBS)
|
||||
|
||||
mostlyclean-compile:
|
||||
-rm -f *.$(OBJEXT)
|
||||
|
||||
distclean-compile:
|
||||
-rm -f *.tab.c
|
||||
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/err.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/scm.Plo@am__quote@
|
||||
|
||||
.c.o:
|
||||
@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
|
||||
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(COMPILE) -c $<
|
||||
|
||||
.c.obj:
|
||||
@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
|
||||
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
|
||||
|
||||
.c.lo:
|
||||
@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
|
||||
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
|
||||
|
||||
mostlyclean-libtool:
|
||||
-rm -f *.lo
|
||||
|
||||
clean-libtool:
|
||||
-rm -rf .libs _libs
|
||||
|
||||
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
|
||||
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
|
||||
unique=`for i in $$list; do \
|
||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
done | \
|
||||
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
|
||||
END { if (nonempty) { for (i in files) print i; }; }'`; \
|
||||
mkid -fID $$unique
|
||||
tags: TAGS
|
||||
|
||||
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
|
||||
$(TAGS_FILES) $(LISP)
|
||||
set x; \
|
||||
here=`pwd`; \
|
||||
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
|
||||
unique=`for i in $$list; do \
|
||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
done | \
|
||||
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
|
||||
END { if (nonempty) { for (i in files) print i; }; }'`; \
|
||||
shift; \
|
||||
if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
|
||||
test -n "$$unique" || unique=$$empty_fix; \
|
||||
if test $$# -gt 0; then \
|
||||
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
|
||||
"$$@" $$unique; \
|
||||
else \
|
||||
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
|
||||
$$unique; \
|
||||
fi; \
|
||||
fi
|
||||
ctags: CTAGS
|
||||
CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
|
||||
$(TAGS_FILES) $(LISP)
|
||||
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
|
||||
unique=`for i in $$list; do \
|
||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
done | \
|
||||
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
|
||||
END { if (nonempty) { for (i in files) print i; }; }'`; \
|
||||
test -z "$(CTAGS_ARGS)$$unique" \
|
||||
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
|
||||
$$unique
|
||||
|
||||
GTAGS:
|
||||
here=`$(am__cd) $(top_builddir) && pwd` \
|
||||
&& $(am__cd) $(top_srcdir) \
|
||||
&& gtags -i $(GTAGS_ARGS) "$$here"
|
||||
|
||||
distclean-tags:
|
||||
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
|
||||
|
||||
distdir: $(DISTFILES)
|
||||
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
|
||||
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
|
||||
list='$(DISTFILES)'; \
|
||||
dist_files=`for file in $$list; do echo $$file; done | \
|
||||
sed -e "s|^$$srcdirstrip/||;t" \
|
||||
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
|
||||
case $$dist_files in \
|
||||
*/*) $(MKDIR_P) `echo "$$dist_files" | \
|
||||
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
|
||||
sort -u` ;; \
|
||||
esac; \
|
||||
for file in $$dist_files; do \
|
||||
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
|
||||
if test -d $$d/$$file; then \
|
||||
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
|
||||
if test -d "$(distdir)/$$file"; then \
|
||||
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
|
||||
fi; \
|
||||
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
|
||||
cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
|
||||
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
|
||||
fi; \
|
||||
cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
|
||||
else \
|
||||
test -f "$(distdir)/$$file" \
|
||||
|| cp -p $$d/$$file "$(distdir)/$$file" \
|
||||
|| exit 1; \
|
||||
fi; \
|
||||
done
|
||||
check-am: all-am
|
||||
check: check-am
|
||||
all-am: Makefile $(LTLIBRARIES)
|
||||
installdirs:
|
||||
for dir in "$(DESTDIR)$(libdir)"; do \
|
||||
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
|
||||
done
|
||||
install: install-am
|
||||
install-exec: install-exec-am
|
||||
install-data: install-data-am
|
||||
uninstall: uninstall-am
|
||||
|
||||
install-am: all-am
|
||||
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
|
||||
|
||||
installcheck: installcheck-am
|
||||
install-strip:
|
||||
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
|
||||
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
|
||||
`test -z '$(STRIP)' || \
|
||||
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
|
||||
mostlyclean-generic:
|
||||
|
||||
clean-generic:
|
||||
|
||||
distclean-generic:
|
||||
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
|
||||
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
|
||||
|
||||
maintainer-clean-generic:
|
||||
@echo "This command is intended for maintainers to use"
|
||||
@echo "it deletes files that may require special tools to rebuild."
|
||||
clean: clean-am
|
||||
|
||||
clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \
|
||||
mostlyclean-am
|
||||
|
||||
distclean: distclean-am
|
||||
-rm -rf ./$(DEPDIR)
|
||||
-rm -f Makefile
|
||||
distclean-am: clean-am distclean-compile distclean-generic \
|
||||
distclean-tags
|
||||
|
||||
dvi: dvi-am
|
||||
|
||||
dvi-am:
|
||||
|
||||
html: html-am
|
||||
|
||||
html-am:
|
||||
|
||||
info: info-am
|
||||
|
||||
info-am:
|
||||
|
||||
install-data-am:
|
||||
|
||||
install-dvi: install-dvi-am
|
||||
|
||||
install-dvi-am:
|
||||
|
||||
install-exec-am: install-libLTLIBRARIES
|
||||
|
||||
install-html: install-html-am
|
||||
|
||||
install-html-am:
|
||||
|
||||
install-info: install-info-am
|
||||
|
||||
install-info-am:
|
||||
|
||||
install-man:
|
||||
|
||||
install-pdf: install-pdf-am
|
||||
|
||||
install-pdf-am:
|
||||
|
||||
install-ps: install-ps-am
|
||||
|
||||
install-ps-am:
|
||||
|
||||
installcheck-am:
|
||||
|
||||
maintainer-clean: maintainer-clean-am
|
||||
-rm -rf ./$(DEPDIR)
|
||||
-rm -f Makefile
|
||||
maintainer-clean-am: distclean-am maintainer-clean-generic
|
||||
|
||||
mostlyclean: mostlyclean-am
|
||||
|
||||
mostlyclean-am: mostlyclean-compile mostlyclean-generic \
|
||||
mostlyclean-libtool
|
||||
|
||||
pdf: pdf-am
|
||||
|
||||
pdf-am:
|
||||
|
||||
ps: ps-am
|
||||
|
||||
ps-am:
|
||||
|
||||
uninstall-am: uninstall-libLTLIBRARIES
|
||||
|
||||
.MAKE: install-am install-strip
|
||||
|
||||
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
|
||||
clean-libLTLIBRARIES clean-libtool ctags distclean \
|
||||
distclean-compile distclean-generic distclean-libtool \
|
||||
distclean-tags distdir dvi dvi-am html html-am info info-am \
|
||||
install install-am install-data install-data-am install-dvi \
|
||||
install-dvi-am install-exec install-exec-am install-html \
|
||||
install-html-am install-info install-info-am \
|
||||
install-libLTLIBRARIES install-man install-pdf install-pdf-am \
|
||||
install-ps install-ps-am install-strip installcheck \
|
||||
installcheck-am installdirs maintainer-clean \
|
||||
maintainer-clean-generic mostlyclean mostlyclean-compile \
|
||||
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
|
||||
tags uninstall uninstall-am uninstall-libLTLIBRARIES
|
||||
|
||||
|
||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||
.NOEXPORT:
|
128
qse/lib/scm/err.c
Normal file
128
qse/lib/scm/err.c
Normal file
@ -0,0 +1,128 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
Copyright 2006-2009 Chung, Hyung-Hwan.
|
||||
This file is part of QSE.
|
||||
|
||||
QSE is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as
|
||||
published by the Free Software Foundation, either version 3 of
|
||||
the License, or (at your option) any later version.
|
||||
|
||||
QSE is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with QSE. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "scm.h"
|
||||
|
||||
const qse_char_t* qse_scm_dflerrstr (qse_scm_t* scm, qse_scm_errnum_t errnum)
|
||||
{
|
||||
static const qse_char_t* errstr[] =
|
||||
{
|
||||
QSE_T("no error"),
|
||||
QSE_T("out of memory"),
|
||||
|
||||
QSE_T("exit"),
|
||||
QSE_T("end of source"),
|
||||
|
||||
QSE_T("I/O error"),
|
||||
QSE_T("unexpected end of string"),
|
||||
|
||||
QSE_T("internal error"),
|
||||
QSE_T("syntax"),
|
||||
QSE_T("list too deep"),
|
||||
QSE_T("right parenthesis expected"),
|
||||
QSE_T("bad arguments"),
|
||||
QSE_T("too few arguments"),
|
||||
QSE_T("too many arguments"),
|
||||
QSE_T("undefined function '${0}'"),
|
||||
QSE_T("bad function"),
|
||||
QSE_T("duplicate formal"),
|
||||
QSE_T("bad symbol"),
|
||||
QSE_T("undefined symbol '${0}'"),
|
||||
QSE_T("empty body"),
|
||||
QSE_T("bad value"),
|
||||
QSE_T("divide by zero")
|
||||
};
|
||||
|
||||
return (errnum >= 0 && errnum < QSE_COUNTOF(errstr))?
|
||||
errstr[errnum]: QSE_T("unknown error");
|
||||
}
|
||||
|
||||
qse_scm_errstr_t qse_scm_geterrstr (qse_scm_t* scm)
|
||||
{
|
||||
return scm->err.str;
|
||||
}
|
||||
|
||||
void qse_scm_seterrstr (qse_scm_t* scm, qse_scm_errstr_t errstr)
|
||||
{
|
||||
scm->err.str = errstr;
|
||||
}
|
||||
|
||||
qse_scm_errnum_t qse_scm_geterrnum (qse_scm_t* scm)
|
||||
{
|
||||
return scm->err.num;
|
||||
}
|
||||
|
||||
const qse_scm_loc_t* qse_scm_geterrloc (qse_scm_t* scm)
|
||||
{
|
||||
return &scm->err.loc;
|
||||
}
|
||||
|
||||
const qse_char_t* qse_scm_geterrmsg (qse_scm_t* scm)
|
||||
{
|
||||
return (scm->err.msg[0] == QSE_T('\0'))?
|
||||
qse_scm_geterrstr(scm)(scm,scm->err.num): scm->err.msg;
|
||||
}
|
||||
|
||||
void qse_scm_geterror (
|
||||
qse_scm_t* scm, qse_scm_errnum_t* errnum,
|
||||
const qse_char_t** errmsg, qse_scm_loc_t* errloc)
|
||||
{
|
||||
if (errnum != QSE_NULL) *errnum = scm->err.num;
|
||||
if (errmsg != QSE_NULL)
|
||||
{
|
||||
*errmsg = (scm->err.msg[0] == QSE_T('\0'))?
|
||||
qse_scm_geterrstr(scm)(scm,scm->err.num):
|
||||
scm->err.msg;
|
||||
}
|
||||
if (errloc != QSE_NULL) *errloc = scm->err.loc;
|
||||
}
|
||||
|
||||
void qse_scm_seterrnum (
|
||||
qse_scm_t* scm, qse_scm_errnum_t errnum, const qse_cstr_t* errarg)
|
||||
{
|
||||
qse_scm_seterror (scm, errnum, errarg, QSE_NULL);
|
||||
}
|
||||
|
||||
void qse_scm_seterrmsg (
|
||||
qse_scm_t* scm, qse_scm_errnum_t errnum,
|
||||
const qse_char_t* errmsg, const qse_scm_loc_t* errloc)
|
||||
{
|
||||
scm->err.num = errnum;
|
||||
qse_strxcpy (scm->err.msg, QSE_COUNTOF(scm->err.msg), errmsg);
|
||||
if (errloc != QSE_NULL) scm->err.loc = *errloc;
|
||||
else QSE_MEMSET (&scm->err.loc, 0, QSE_SIZEOF(scm->err.loc));
|
||||
}
|
||||
|
||||
void qse_scm_seterror (
|
||||
qse_scm_t* scm, qse_scm_errnum_t errnum,
|
||||
const qse_cstr_t* errarg, const qse_scm_loc_t* errloc)
|
||||
{
|
||||
const qse_char_t* errfmt;
|
||||
|
||||
scm->err.num = errnum;
|
||||
|
||||
errfmt = qse_scm_geterrstr(scm)(scm,scm->err.num);
|
||||
QSE_ASSERT (errfmt != QSE_NULL);
|
||||
qse_strxfncpy (scm->err.msg, QSE_COUNTOF(scm->err.msg), errfmt, errarg);
|
||||
|
||||
if (errloc != QSE_NULL) scm->err.loc = *errloc;
|
||||
else QSE_MEMSET (&scm->err.loc, 0, QSE_SIZEOF(scm->err.loc));
|
||||
}
|
||||
|
600
qse/lib/scm/mem.c
Normal file
600
qse/lib/scm/mem.c
Normal file
@ -0,0 +1,600 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
Copyright 2006-2009 Chung, Hyung-Hwan.
|
||||
This file is part of QSE.
|
||||
|
||||
QSE is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as
|
||||
published by the Free Software Foundation, either version 3 of
|
||||
the License, or (at your option) any later version.
|
||||
|
||||
QSE is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with QSE. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "scm.h"
|
||||
|
||||
static qse_scm_obj_t* makeint (qse_scm_mem_t* mem, qse_long_t value);
|
||||
static QSE_INLINE_ALWAYS void collect_garbage (qse_scm_mem_t* mem);
|
||||
static void dispose_all (qse_scm_mem_t* mem);
|
||||
|
||||
qse_scm_mem_t* qse_scm_initmem (
|
||||
qse_scm_mem_t* mem, qse_scm_t* scm,
|
||||
qse_size_t ubound, qse_size_t ubound_inc)
|
||||
{
|
||||
qse_size_t i;
|
||||
int fail = 0;
|
||||
|
||||
QSE_MEMSET (mem, 0, QSE_SIZEOF(qse_scm_mem_t));
|
||||
mem->scm = scm;
|
||||
|
||||
/* create a new root environment frame */
|
||||
mem->frame = qse_scm_newframe (scm);
|
||||
if (mem->frame == QSE_NULL) return QSE_NULL;
|
||||
|
||||
mem->root_frame = mem->frame;
|
||||
mem->brooding_frame = QSE_NULL;
|
||||
mem->tlink = QSE_NULL;
|
||||
mem->tlink_count = 0;
|
||||
|
||||
/* initialize object allocation list */
|
||||
mem->ubound = ubound;
|
||||
mem->ubound_inc = ubound_inc;
|
||||
mem->count = 0;
|
||||
for (i = 0; i < QSE_SCM_TYPE_COUNT; i++)
|
||||
{
|
||||
mem->used[i] = QSE_NULL;
|
||||
mem->free[i] = QSE_NULL;
|
||||
}
|
||||
|
||||
/* initialize read registers */
|
||||
mem->r.obj = QSE_NULL;
|
||||
mem->r.tmp = QSE_NULL;
|
||||
mem->r.stack = QSE_NULL;
|
||||
|
||||
/* when "ubound" is too small, the garbage collection can
|
||||
* be performed while making the common objects. */
|
||||
mem->nil = QSE_NULL;
|
||||
mem->t = QSE_NULL;
|
||||
mem->quote = QSE_NULL;
|
||||
mem->lambda = QSE_NULL;
|
||||
mem->macro = QSE_NULL;
|
||||
for (i = 0; i < QSE_COUNTOF(mem->num); i++) mem->num[i] = QSE_NULL;
|
||||
|
||||
/* initialize common object pointers */
|
||||
mem->nil = qse_scm_makenil (mem);
|
||||
mem->t = qse_scm_maketrue (mem);
|
||||
mem->quote = qse_scm_makesym (mem, QSE_T("quote"), 5);
|
||||
mem->lambda = qse_scm_makesym (mem, QSE_T("lambda"), 6);
|
||||
mem->macro = qse_scm_makesym (mem, QSE_T("macro"), 5);
|
||||
|
||||
if (mem->nil == QSE_NULL ||
|
||||
mem->t == QSE_NULL ||
|
||||
mem->quote == QSE_NULL ||
|
||||
mem->lambda == QSE_NULL ||
|
||||
mem->macro == QSE_NULL)
|
||||
{
|
||||
fail = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = 0; i < QSE_COUNTOF(mem->num); i++)
|
||||
{
|
||||
mem->num[i] = makeint (mem, i);
|
||||
if (mem->num[i] == QSE_NULL) { fail = 1; break; }
|
||||
}
|
||||
}
|
||||
|
||||
if (fail)
|
||||
{
|
||||
dispose_all (mem);
|
||||
qse_scm_freeframe (scm, mem->frame);
|
||||
return QSE_NULL;
|
||||
}
|
||||
|
||||
QSE_SCM_PERM(mem->nil) = 1;
|
||||
QSE_SCM_PERM(mem->t) = 1;
|
||||
QSE_SCM_PERM(mem->quote) = 1;
|
||||
QSE_SCM_PERM(mem->lambda) = 1;
|
||||
QSE_SCM_PERM(mem->macro) = 1;
|
||||
for (i = 0; i < QSE_COUNTOF(mem->num); i++)
|
||||
{
|
||||
QSE_SCM_PERM(mem->num[i]) = 1;
|
||||
}
|
||||
|
||||
/* let the read stack point to nil */
|
||||
mem->r.stack = mem->nil;
|
||||
|
||||
return mem;
|
||||
}
|
||||
|
||||
void qse_scm_finimem (qse_scm_mem_t* mem)
|
||||
{
|
||||
/* dispose of the allocated objects */
|
||||
dispose_all (mem);
|
||||
|
||||
/* dispose of environment frames */
|
||||
qse_scm_freeframe (mem->scm, mem->frame);
|
||||
}
|
||||
|
||||
static qse_scm_obj_t* allocate (qse_scm_mem_t* mem, int type, qse_size_t size)
|
||||
{
|
||||
qse_scm_obj_t* obj;
|
||||
|
||||
if (mem->count >= mem->ubound) collect_garbage (mem);
|
||||
if (mem->count >= mem->ubound)
|
||||
{
|
||||
mem->ubound += mem->ubound_inc;
|
||||
if (mem->count >= mem->ubound) return QSE_NULL;
|
||||
}
|
||||
|
||||
obj = (qse_scm_obj_t*) QSE_SCM_ALLOC (mem->scm, size);
|
||||
if (obj == QSE_NULL)
|
||||
{
|
||||
collect_garbage (mem);
|
||||
|
||||
obj = (qse_scm_obj_t*) QSE_SCM_ALLOC (mem->scm, size);
|
||||
if (obj == QSE_NULL)
|
||||
{
|
||||
qse_scm_seterror (mem->scm, QSE_SCM_ENOMEM, QSE_NULL, 0);
|
||||
return QSE_NULL;
|
||||
}
|
||||
}
|
||||
|
||||
QSE_SCM_TYPE(obj) = type;
|
||||
QSE_SCM_SIZE(obj) = size;
|
||||
QSE_SCM_MARK(obj) = 0;
|
||||
QSE_SCM_PERM(obj) = 0;
|
||||
|
||||
/* insert the object at the head of the used list */
|
||||
QSE_SCM_LINK(obj) = mem->used[type];
|
||||
mem->used[type] = obj;
|
||||
mem->count++;
|
||||
|
||||
#if 0
|
||||
qse_dprint1 (QSE_T("mem->count: %u\n"), mem->count);
|
||||
#endif
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
static void dispose (
|
||||
qse_scm_mem_t* mem, qse_scm_obj_t* prev, qse_scm_obj_t* obj)
|
||||
{
|
||||
QSE_ASSERT (obj != QSE_NULL);
|
||||
QSE_ASSERT (mem->count > 0);
|
||||
|
||||
/* TODO: push the object to the free list for more
|
||||
* efficient memory management */
|
||||
|
||||
if (prev == QSE_NULL)
|
||||
mem->used[QSE_SCM_TYPE(obj)] = QSE_SCM_LINK(obj);
|
||||
else QSE_SCM_LINK(prev) = QSE_SCM_LINK(obj);
|
||||
|
||||
mem->count--;
|
||||
#if 0
|
||||
qse_dprint1 (QSE_T("mem->count: %u\n"), mem->count);
|
||||
#endif
|
||||
|
||||
QSE_SCM_FREE (mem->scm, obj);
|
||||
}
|
||||
|
||||
static void dispose_all (qse_scm_mem_t* mem)
|
||||
{
|
||||
qse_scm_obj_t* obj, * next;
|
||||
qse_size_t i;
|
||||
|
||||
for (i = 0; i < QSE_SCM_TYPE_COUNT; i++)
|
||||
{
|
||||
obj = mem->used[i];
|
||||
|
||||
while (obj != QSE_NULL)
|
||||
{
|
||||
next = QSE_SCM_LINK(obj);
|
||||
dispose (mem, QSE_NULL, obj);
|
||||
obj = next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void mark_obj (qse_scm_mem_t* mem, qse_scm_obj_t* obj)
|
||||
{
|
||||
QSE_ASSERT (obj != QSE_NULL);
|
||||
|
||||
/* TODO: can it be non-recursive? */
|
||||
if (QSE_SCM_MARK(obj) != 0) return;
|
||||
|
||||
QSE_SCM_MARK(obj) = 1;
|
||||
|
||||
if (QSE_SCM_TYPE(obj) == QSE_SCM_OBJ_CONS)
|
||||
{
|
||||
mark_obj (mem, QSE_SCM_CAR(obj));
|
||||
mark_obj (mem, QSE_SCM_CDR(obj));
|
||||
}
|
||||
else if (QSE_SCM_TYPE(obj) == QSE_SCM_OBJ_FUNC)
|
||||
{
|
||||
mark_obj (mem, QSE_SCM_FFORMAL(obj));
|
||||
mark_obj (mem, QSE_SCM_FBODY(obj));
|
||||
}
|
||||
else if (QSE_SCM_TYPE(obj) == QSE_SCM_OBJ_MACRO)
|
||||
{
|
||||
mark_obj (mem, QSE_SCM_MFORMAL(obj));
|
||||
mark_obj (mem, QSE_SCM_MBODY(obj));
|
||||
}
|
||||
}
|
||||
|
||||
static void mark_objs_in_use (qse_scm_mem_t* mem)
|
||||
{
|
||||
qse_scm_frame_t* frame;
|
||||
qse_scm_assoc_t* assoc;
|
||||
qse_scm_tlink_t* tlink;
|
||||
/*qse_scm_arr_t* arr;*/
|
||||
qse_size_t i;
|
||||
|
||||
#if 0
|
||||
qse_dprint0 (QSE_T("marking environment frames\n"));
|
||||
#endif
|
||||
/* mark objects in the environment frames */
|
||||
frame = mem->frame;
|
||||
while (frame != QSE_NULL)
|
||||
{
|
||||
assoc = frame->assoc;
|
||||
while (assoc != QSE_NULL)
|
||||
{
|
||||
mark_obj (mem, assoc->name);
|
||||
|
||||
if (assoc->value != QSE_NULL)
|
||||
mark_obj (mem, assoc->value);
|
||||
if (assoc->func != QSE_NULL)
|
||||
mark_obj (mem, assoc->func);
|
||||
|
||||
assoc = assoc->link;
|
||||
}
|
||||
|
||||
frame = frame->link;
|
||||
}
|
||||
|
||||
#if 0
|
||||
qse_dprint0 (QSE_T("marking interim frames\n"));
|
||||
#endif
|
||||
|
||||
/* mark objects in the interim frames */
|
||||
frame = mem->brooding_frame;
|
||||
while (frame != QSE_NULL)
|
||||
{
|
||||
assoc = frame->assoc;
|
||||
while (assoc != QSE_NULL)
|
||||
{
|
||||
mark_obj (mem, assoc->name);
|
||||
|
||||
if (assoc->value != QSE_NULL)
|
||||
mark_obj (mem, assoc->value);
|
||||
if (assoc->func != QSE_NULL)
|
||||
mark_obj (mem, assoc->func);
|
||||
|
||||
assoc = assoc->link;
|
||||
}
|
||||
|
||||
frame = frame->link;
|
||||
}
|
||||
|
||||
/*qse_dprint0 (QSE_T("marking the read object\n"));*/
|
||||
if (mem->r.obj) mark_obj (mem, mem->r.obj);
|
||||
if (mem->r.tmp) mark_obj (mem, mem->r.tmp);
|
||||
if (mem->r.stack) mark_obj (mem, mem->r.stack);
|
||||
|
||||
/* qse_dprint0 (QSE_T("marking the temporary objects\n"));*/
|
||||
for (tlink = mem->tlink; tlink != QSE_NULL; tlink = tlink->link)
|
||||
{
|
||||
mark_obj (mem, tlink->obj);
|
||||
}
|
||||
|
||||
#if 0
|
||||
qse_dprint0 (QSE_T("marking builtin objects\n"));
|
||||
#endif
|
||||
/* mark common objects */
|
||||
if (mem->t) mark_obj (mem, mem->t);
|
||||
if (mem->nil) mark_obj (mem, mem->nil);
|
||||
if (mem->quote) mark_obj (mem, mem->quote);
|
||||
if (mem->lambda) mark_obj (mem, mem->lambda);
|
||||
if (mem->macro) mark_obj (mem, mem->macro);
|
||||
|
||||
for (i = 0; i < QSE_COUNTOF(mem->num); i++)
|
||||
{
|
||||
if (mem->num[i]) mark_obj (mem, mem->num[i]);
|
||||
}
|
||||
}
|
||||
|
||||
//#include <qse/cmn/stdio.h>
|
||||
static void sweep_unmarked_objs (qse_scm_mem_t* mem)
|
||||
{
|
||||
qse_scm_obj_t* obj, * prev, * next;
|
||||
qse_size_t i;
|
||||
|
||||
/* scan all the allocated objects and get rid of unused objects */
|
||||
for (i = 0; i < QSE_SCM_TYPE_COUNT; i++)
|
||||
{
|
||||
prev = QSE_NULL;
|
||||
obj = mem->used[i];
|
||||
|
||||
#if 0
|
||||
qse_dprint1 (QSE_T("sweeping objects of type: %u\n"), i);
|
||||
#endif
|
||||
while (obj != QSE_NULL)
|
||||
{
|
||||
next = QSE_SCM_LINK(obj);
|
||||
|
||||
if (QSE_SCM_MARK(obj) == 0 &&
|
||||
QSE_SCM_PERM(obj) == 0)
|
||||
{
|
||||
/* dispose of unused objects */
|
||||
/*
|
||||
if (i == QSE_SCM_OBJ_INT)
|
||||
qse_printf (QSE_T("disposing....%d [%d]\n"), i, (int)QSE_SCM_IVAL(obj));
|
||||
if (i == QSE_SCM_OBJ_REAL)
|
||||
qse_printf (QSE_T("disposing....%d [%Lf]\n"), i, (double)QSE_SCM_RVAL(obj));
|
||||
else if (i == QSE_SCM_OBJ_SYM)
|
||||
qse_printf (QSE_T("disposing....%d [%s]\n"), i, QSE_SCM_SYMPTR(obj));
|
||||
else if (i == QSE_SCM_OBJ_STR)
|
||||
qse_printf (QSE_T("disposing....%d [%s]\n"), i, QSE_SCM_STRPTR(obj));
|
||||
else
|
||||
qse_printf (QSE_T("disposing....%d\n"), i);
|
||||
*/
|
||||
dispose (mem, prev, obj);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* unmark the object in use */
|
||||
QSE_SCM_MARK(obj) = 0;
|
||||
prev = obj;
|
||||
}
|
||||
|
||||
obj = next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static QSE_INLINE_ALWAYS void collect_garbage (qse_scm_mem_t* mem)
|
||||
{
|
||||
mark_objs_in_use (mem);
|
||||
sweep_unmarked_objs (mem);
|
||||
}
|
||||
|
||||
void qse_scm_gc (qse_scm_t* scm)
|
||||
{
|
||||
collect_garbage (&scm->mem);
|
||||
}
|
||||
|
||||
qse_scm_obj_t* qse_scm_makenil (qse_scm_mem_t* mem)
|
||||
{
|
||||
if (mem->nil != QSE_NULL) return mem->nil;
|
||||
mem->nil = allocate (
|
||||
mem, QSE_SCM_OBJ_NIL, QSE_SIZEOF(qse_scm_obj_nil_t));
|
||||
return mem->nil;
|
||||
}
|
||||
|
||||
qse_scm_obj_t* qse_scm_maketrue (qse_scm_mem_t* mem)
|
||||
{
|
||||
if (mem->t != QSE_NULL) return mem->t;
|
||||
mem->t = allocate (
|
||||
mem, QSE_SCM_OBJ_TRUE, QSE_SIZEOF(qse_scm_obj_true_t));
|
||||
return mem->t;
|
||||
}
|
||||
|
||||
static qse_scm_obj_t* makeint (qse_scm_mem_t* mem, qse_long_t value)
|
||||
{
|
||||
qse_scm_obj_t* obj;
|
||||
|
||||
obj = allocate (mem,
|
||||
QSE_SCM_OBJ_INT, QSE_SIZEOF(qse_scm_obj_int_t));
|
||||
if (obj == QSE_NULL) return QSE_NULL;
|
||||
|
||||
QSE_SCM_IVAL(obj) = value;
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
qse_scm_obj_t* qse_scm_makeint (qse_scm_mem_t* mem, qse_long_t value)
|
||||
{
|
||||
if (value >= 0 && value < QSE_COUNTOF(mem->num)) return mem->num[value];
|
||||
return makeint (mem, value);
|
||||
}
|
||||
|
||||
qse_scm_obj_t* qse_scm_makereal (qse_scm_mem_t* mem, qse_real_t value)
|
||||
{
|
||||
qse_scm_obj_t* obj;
|
||||
|
||||
obj = allocate (mem,
|
||||
QSE_SCM_OBJ_REAL, QSE_SIZEOF(qse_scm_obj_real_t));
|
||||
if (obj == QSE_NULL) return QSE_NULL;
|
||||
|
||||
QSE_SCM_RVAL(obj) = value;
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
qse_scm_obj_t* qse_scm_makesym (
|
||||
qse_scm_mem_t* mem, const qse_char_t* str, qse_size_t len)
|
||||
{
|
||||
qse_scm_obj_t* obj;
|
||||
|
||||
/* TODO: use rbt or htb ... */
|
||||
|
||||
/* look for a sysmbol with the given name */
|
||||
obj = mem->used[QSE_SCM_OBJ_SYM];
|
||||
while (obj != QSE_NULL)
|
||||
{
|
||||
/* if there is a symbol with the same name, it is just used. */
|
||||
if (qse_strxncmp (
|
||||
QSE_SCM_SYMPTR(obj),
|
||||
QSE_SCM_SYMLEN(obj),
|
||||
str, len) == 0) return obj;
|
||||
obj = QSE_SCM_LINK(obj);
|
||||
}
|
||||
|
||||
/* no such symbol found. create a new one */
|
||||
obj = allocate (mem, QSE_SCM_OBJ_SYM,
|
||||
QSE_SIZEOF(qse_scm_obj_sym_t)+(len + 1)*QSE_SIZEOF(qse_char_t));
|
||||
if (obj == QSE_NULL) return QSE_NULL;
|
||||
|
||||
/* fill in the symbol buffer */
|
||||
qse_strncpy (QSE_SCM_SYMPTR(obj), str, len);
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
qse_scm_obj_t* qse_scm_makestr (
|
||||
qse_scm_mem_t* mem, const qse_char_t* str, qse_size_t len)
|
||||
{
|
||||
qse_scm_obj_t* obj;
|
||||
|
||||
/* allocate memory for the string */
|
||||
obj = allocate (mem, QSE_SCM_OBJ_STR,
|
||||
QSE_SIZEOF(qse_scm_obj_str_t)+(len + 1)*QSE_SIZEOF(qse_char_t));
|
||||
if (obj == QSE_NULL) return QSE_NULL;
|
||||
|
||||
/* fill in the string buffer */
|
||||
qse_strncpy (QSE_SCM_STRPTR(obj), str, len);
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
qse_scm_obj_t* qse_scm_makecons (
|
||||
qse_scm_mem_t* mem, qse_scm_obj_t* car, qse_scm_obj_t* cdr)
|
||||
{
|
||||
qse_scm_obj_t* obj;
|
||||
|
||||
obj = allocate (mem,
|
||||
QSE_SCM_OBJ_CONS, QSE_SIZEOF(qse_scm_obj_cons_t));
|
||||
if (obj == QSE_NULL) return QSE_NULL;
|
||||
|
||||
QSE_SCM_CAR(obj) = car;
|
||||
QSE_SCM_CDR(obj) = cdr;
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
qse_scm_obj_t* qse_scm_makefunc (
|
||||
qse_scm_mem_t* mem, qse_scm_obj_t* formal, qse_scm_obj_t* body)
|
||||
{
|
||||
qse_scm_obj_t* obj;
|
||||
|
||||
obj = allocate (mem,
|
||||
QSE_SCM_OBJ_FUNC, QSE_SIZEOF(qse_scm_obj_func_t));
|
||||
if (obj == QSE_NULL) return QSE_NULL;
|
||||
|
||||
QSE_SCM_FFORMAL(obj) = formal;
|
||||
QSE_SCM_FBODY(obj) = body;
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
qse_scm_obj_t* qse_scm_makemacro (
|
||||
qse_scm_mem_t* mem, qse_scm_obj_t* formal, qse_scm_obj_t* body)
|
||||
{
|
||||
qse_scm_obj_t* obj;
|
||||
|
||||
obj = allocate (mem,
|
||||
QSE_SCM_OBJ_MACRO, QSE_SIZEOF(qse_scm_obj_macro_t));
|
||||
if (obj == QSE_NULL) return QSE_NULL;
|
||||
|
||||
QSE_SCM_MFORMAL(obj) = formal;
|
||||
QSE_SCM_MBODY(obj) = body;
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
qse_scm_obj_t* qse_scm_makeprim (qse_scm_mem_t* mem,
|
||||
qse_scm_prim_t impl, qse_size_t min_args, qse_size_t max_args)
|
||||
{
|
||||
qse_scm_obj_t* obj;
|
||||
|
||||
obj = allocate (
|
||||
mem, QSE_SCM_OBJ_PRIM, QSE_SIZEOF(qse_scm_obj_prim_t));
|
||||
if (obj == QSE_NULL) return QSE_NULL;
|
||||
|
||||
QSE_SCM_PIMPL(obj) = impl;
|
||||
QSE_SCM_PMINARGS(obj) = min_args;
|
||||
QSE_SCM_PMAXARGS(obj) = max_args;
|
||||
return obj;
|
||||
}
|
||||
|
||||
qse_scm_assoc_t* qse_scm_lookup (qse_scm_mem_t* mem, qse_scm_obj_t* name)
|
||||
{
|
||||
qse_scm_frame_t* frame;
|
||||
qse_scm_assoc_t* assoc;
|
||||
|
||||
QSE_ASSERT (QSE_SCM_TYPE(name) == QSE_SCM_OBJ_SYM);
|
||||
|
||||
frame = mem->frame;
|
||||
|
||||
while (frame != QSE_NULL)
|
||||
{
|
||||
assoc = qse_scm_lookupinframe (mem->scm, frame, name);
|
||||
if (assoc != QSE_NULL) return assoc;
|
||||
frame = frame->link;
|
||||
}
|
||||
|
||||
return QSE_NULL;
|
||||
}
|
||||
|
||||
qse_scm_assoc_t* qse_scm_setvalue (
|
||||
qse_scm_mem_t* mem, qse_scm_obj_t* name, qse_scm_obj_t* value)
|
||||
{
|
||||
qse_scm_assoc_t* assoc;
|
||||
|
||||
assoc = qse_scm_lookup (mem, name);
|
||||
if (assoc == QSE_NULL)
|
||||
{
|
||||
assoc = qse_scm_insvalueintoframe (
|
||||
mem->scm, mem->root_frame, name, value);
|
||||
if (assoc == QSE_NULL) return QSE_NULL;
|
||||
}
|
||||
else assoc->value = value;
|
||||
|
||||
return assoc;
|
||||
}
|
||||
|
||||
qse_scm_assoc_t* qse_scm_setfunc (
|
||||
qse_scm_mem_t* mem, qse_scm_obj_t* name, qse_scm_obj_t* func)
|
||||
{
|
||||
qse_scm_assoc_t* assoc;
|
||||
|
||||
assoc = qse_scm_lookup (mem, name);
|
||||
if (assoc == QSE_NULL)
|
||||
{
|
||||
assoc = qse_scm_insfuncintoframe (
|
||||
mem->scm, mem->root_frame, name, func);
|
||||
if (assoc == QSE_NULL) return QSE_NULL;
|
||||
}
|
||||
else assoc->func = func;
|
||||
|
||||
return assoc;
|
||||
}
|
||||
|
||||
qse_size_t qse_scm_conslen (qse_scm_mem_t* mem, qse_scm_obj_t* obj)
|
||||
{
|
||||
qse_size_t count;
|
||||
|
||||
QSE_ASSERT (
|
||||
obj == mem->nil || QSE_SCM_TYPE(obj) == QSE_SCM_OBJ_CONS);
|
||||
|
||||
count = 0;
|
||||
/*while (obj != mem->nil) {*/
|
||||
while (QSE_SCM_TYPE(obj) == QSE_SCM_OBJ_CONS)
|
||||
{
|
||||
count++;
|
||||
obj = QSE_SCM_CDR(obj);
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
|
100
qse/lib/scm/mem.h
Normal file
100
qse/lib/scm/mem.h
Normal file
@ -0,0 +1,100 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
Copyright 2006-2009 Chung, Hyung-Hwan.
|
||||
This file is part of QSE.
|
||||
|
||||
QSE is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as
|
||||
published by the Free Software Foundation, either version 3 of
|
||||
the License, or (at your option) any later version.
|
||||
|
||||
QSE is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with QSE. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _QSE_LIB_SCM_MEM_H_
|
||||
#define _QSE_LIB_SCM_MEM_H_
|
||||
|
||||
#ifndef _QSE_SCM_SCM_H_
|
||||
#error Never include this file directly. Include <qse/scm/scm.h> instead
|
||||
#endif
|
||||
|
||||
enum
|
||||
{
|
||||
QSE_SCM_OBJ_NIL = 0,
|
||||
QSE_SCM_OBJ_TRUE,
|
||||
QSE_SCM_OBJ_INT,
|
||||
QSE_SCM_OBJ_REAL,
|
||||
QSE_SCM_OBJ_SYM,
|
||||
QSE_SCM_OBJ_STR,
|
||||
QSE_SCM_OBJ_CONS,
|
||||
QSE_SCM_OBJ_FUNC,
|
||||
QSE_SCM_OBJ_MACRO,
|
||||
QSE_SCM_OBJ_PRIM,
|
||||
|
||||
QSE_SCM_TYPE_COUNT /* the number of lsp object types */
|
||||
};
|
||||
|
||||
|
||||
typedef struct qse_scm_mem_t qse_scm_mem_t;
|
||||
|
||||
struct qse_scm_mem_t
|
||||
{
|
||||
qse_scm_t* scm;
|
||||
|
||||
/* object allocation list */
|
||||
qse_size_t ubound; /* upper bounds of the maximum number of objects */
|
||||
qse_size_t ubound_inc; /* increment of the upper bounds */
|
||||
qse_size_t count; /* the number of objects currently allocated */
|
||||
qse_scm_obj_t* used[QSE_SCM_TYPE_COUNT];
|
||||
qse_scm_obj_t* free[QSE_SCM_TYPE_COUNT];
|
||||
|
||||
struct
|
||||
{
|
||||
qse_scm_obj_t* obj;
|
||||
qse_scm_obj_t* tmp; /* temporary datum to protect from gc in read() */
|
||||
qse_scm_obj_t* stack;
|
||||
} r;
|
||||
|
||||
/* commonly accessed objects */
|
||||
qse_scm_obj_t* nil; /* qse_scm_obj_nil_t */
|
||||
qse_scm_obj_t* t; /* qse_scm_obj_true_t */
|
||||
qse_scm_obj_t* quote; /* qse_scm_obj_sym_t */
|
||||
qse_scm_obj_t* lambda; /* qse_scm_obj_sym_t */
|
||||
qse_scm_obj_t* macro; /* qse_scm_obj_sym_t */
|
||||
qse_scm_obj_t* num[10]; /* qse_scm_obj_int_t */
|
||||
|
||||
#if 0
|
||||
/* run-time environment frame */
|
||||
qse_scm_frame_t* frame;
|
||||
/* pointer to a global-level frame */
|
||||
qse_scm_frame_t* root_frame;
|
||||
/* pointer to an interim frame not yet added to "frame" */
|
||||
qse_scm_frame_t* brooding_frame;
|
||||
|
||||
/* links for temporary objects */
|
||||
qse_scm_tlink_t* tlink;
|
||||
qse_size_t tlink_count;
|
||||
#endif
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
qse_scm_mem_t* qse_scm_initmem (
|
||||
qse_scm_mem_t* mem, qse_scm_t* scm,
|
||||
qse_size_t ubound, qse_size_t ubound_inc);
|
||||
void qse_scm_finimem (qse_scm_mem_t* mem);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
168
qse/lib/scm/scm.c
Normal file
168
qse/lib/scm/scm.c
Normal file
@ -0,0 +1,168 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
Copyright 2006-2009 Chung, Hyung-Hwan.
|
||||
This file is part of QSE.
|
||||
|
||||
QSE is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as
|
||||
published by the Free Software Foundation, either version 3 of
|
||||
the License, or (at your option) any later version.
|
||||
|
||||
QSE is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with QSE. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "scm.h"
|
||||
|
||||
QSE_IMPLEMENT_COMMON_FUNCTIONS (scm)
|
||||
|
||||
static qse_scm_t* qse_scm_init (
|
||||
qse_scm_t* scm,
|
||||
qse_mmgr_t* mmgr,
|
||||
const qse_scm_prm_t* prm,
|
||||
qse_size_t mem_ubound,
|
||||
qse_size_t mem_ubound_inc
|
||||
);
|
||||
|
||||
static void qse_scm_fini (qse_scm_t* scm);
|
||||
|
||||
qse_scm_t* qse_scm_open (
|
||||
qse_mmgr_t* mmgr, qse_size_t xtnsize, const qse_scm_prm_t* prm,
|
||||
qse_size_t mem_ubound, qse_size_t mem_ubound_inc)
|
||||
{
|
||||
qse_scm_t* scm;
|
||||
|
||||
if (mmgr == QSE_NULL)
|
||||
{
|
||||
mmgr = QSE_MMGR_GETDFL();
|
||||
|
||||
QSE_ASSERTX (mmgr != QSE_NULL,
|
||||
"Set the memory manager with QSE_MMGR_SETDFL()");
|
||||
|
||||
if (mmgr == QSE_NULL) return QSE_NULL;
|
||||
}
|
||||
|
||||
scm = (qse_scm_t*) QSE_MMGR_ALLOC (mmgr, QSE_SIZEOF(qse_scm_t) + xtnsize);
|
||||
if (scm == QSE_NULL) return QSE_NULL;
|
||||
|
||||
if (qse_scm_init (scm, mmgr, prm, mem_ubound, mem_ubound_inc) == QSE_NULL)
|
||||
{
|
||||
QSE_MMGR_FREE (scm->mmgr, scm);
|
||||
return QSE_NULL;
|
||||
}
|
||||
|
||||
return scm;
|
||||
}
|
||||
|
||||
void qse_scm_close (qse_scm_t* scm)
|
||||
{
|
||||
qse_scm_fini (scm);
|
||||
QSE_SCM_FREE (scm, scm);
|
||||
}
|
||||
|
||||
static qse_scm_t* qse_scm_init (
|
||||
qse_scm_t* scm, qse_mmgr_t* mmgr, const qse_scm_prm_t* prm,
|
||||
qse_size_t mem_ubound, qse_size_t mem_ubound_inc)
|
||||
{
|
||||
if (mmgr == QSE_NULL) mmgr = QSE_MMGR_GETDFL();
|
||||
|
||||
QSE_MEMSET (scm, 0, QSE_SIZEOF(*scm));
|
||||
|
||||
scm->mmgr = mmgr;
|
||||
scm->prm = *prm;
|
||||
|
||||
/* set the default error string function */
|
||||
scm->err.str = qse_scm_dflerrstr;
|
||||
|
||||
/* initialize error data */
|
||||
scm->err.num = QSE_SCM_ENOERR;
|
||||
scm->err.msg[0] = QSE_T('\0');
|
||||
|
||||
/* initialize read data */
|
||||
scm->r.curc = QSE_CHAR_EOF;
|
||||
scm->r.curloc.line = 1;
|
||||
scm->r.curloc.colm = 0;
|
||||
|
||||
if (qse_str_init(&scm->r.t.name, mmgr, 256) == QSE_NULL)
|
||||
{
|
||||
QSE_SCM_FREE (scm, scm);
|
||||
return QSE_NULL;
|
||||
}
|
||||
|
||||
/* initialize memory manager */
|
||||
#if 0
|
||||
if (qse_scm_initmem (
|
||||
&scm->mem, scm, mem_ubound, mem_ubound_inc) == QSE_NULL)
|
||||
{
|
||||
qse_str_fini (&scm->r.t.name);
|
||||
QSE_SCM_FREE (scm, scm);
|
||||
return QSE_NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
return scm;
|
||||
}
|
||||
|
||||
static void qse_scm_fini (qse_scm_t* scm)
|
||||
{
|
||||
#if 0
|
||||
qse_scm_finimem (&scm->mem);
|
||||
#endif
|
||||
qse_str_fini (&scm->r.t.name);
|
||||
}
|
||||
|
||||
void qse_scm_detachio (qse_scm_t* scm)
|
||||
{
|
||||
if (scm->io.fns.out)
|
||||
{
|
||||
scm->io.fns.out (scm, QSE_SCM_IO_CLOSE, &scm->io.arg.out, QSE_NULL, 0);
|
||||
scm->io.fns.out = QSE_NULL;
|
||||
}
|
||||
|
||||
if (scm->io.fns.in)
|
||||
{
|
||||
scm->io.fns.in (scm, QSE_SCM_IO_CLOSE, &scm->io.arg.in, QSE_NULL, 0);
|
||||
scm->io.fns.in = QSE_NULL;
|
||||
|
||||
scm->r.curc = QSE_CHAR_EOF; /* TODO: needed??? */
|
||||
}
|
||||
}
|
||||
|
||||
int qse_scm_attachio (qse_scm_t* scm, qse_scm_io_t* io)
|
||||
{
|
||||
qse_scm_detachio(scm);
|
||||
|
||||
QSE_ASSERT (scm->io.fns.in == QSE_NULL);
|
||||
QSE_ASSERT (scm->io.fns.out == QSE_NULL);
|
||||
|
||||
scm->err.num = QSE_SCM_ENOERR;
|
||||
if (io->in (scm, QSE_SCM_IO_OPEN, &scm->io.arg.in, QSE_NULL, 0) <= -1)
|
||||
{
|
||||
if (scm->err.num == QSE_SCM_ENOERR)
|
||||
qse_scm_seterror (scm, QSE_SCM_EIO, QSE_NULL, QSE_NULL);
|
||||
return -1;
|
||||
}
|
||||
|
||||
scm->err.num = QSE_SCM_ENOERR;
|
||||
if (io->out (scm, QSE_SCM_IO_OPEN, &scm->io.arg.out, QSE_NULL, 0) <= -1)
|
||||
{
|
||||
if (scm->err.num == QSE_SCM_ENOERR)
|
||||
qse_scm_seterror (scm,QSE_SCM_EIO, QSE_NULL, QSE_NULL);
|
||||
io->in (scm, QSE_SCM_IO_CLOSE, &scm->io.arg.in, QSE_NULL, 0);
|
||||
return -1;
|
||||
}
|
||||
|
||||
scm->io.fns = *io;
|
||||
scm->r.curc = QSE_CHAR_EOF;
|
||||
scm->r.curloc.line = 1;
|
||||
scm->r.curloc.colm = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
115
qse/lib/scm/scm.h
Normal file
115
qse/lib/scm/scm.h
Normal file
@ -0,0 +1,115 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
Copyright 2006-2009 Chung, Hyung-Hwan.
|
||||
This file is part of QSE.
|
||||
|
||||
QSE is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as
|
||||
published by the Free Software Foundation, either version 3 of
|
||||
the License, or (at your option) any later version.
|
||||
|
||||
QSE is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with QSE. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _QSE_LIB_SCM_SCM_H_
|
||||
#define _QSE_LIB_SCM_SCM_H_
|
||||
|
||||
#include "../cmn/mem.h"
|
||||
#include <qse/cmn/chr.h>
|
||||
#include <qse/cmn/str.h>
|
||||
#include <qse/scm/scm.h>
|
||||
|
||||
#include "mem.h"
|
||||
|
||||
#define QSE_SCM_ALLOC(scm,size) QSE_MMGR_ALLOC((scm)->mmgr,size)
|
||||
#define QSE_SCM_REALLOC(scm,ptr,size) QSE_MMGR_REALLOC((scm)->mmgr,ptr,size)
|
||||
#define QSE_SCM_FREE(scm,ptr) QSE_MMGR_FREE((scm)->mmgr,ptr)
|
||||
|
||||
#define QSE_SCM_ISUPPER(scm,c) QSE_ISUPPER(c)
|
||||
#define QSE_SCM_ISLOWER(scm,c) QSE_ISLOWER(c)
|
||||
#define QSE_SCM_ISALPHA(scm,c) QSE_ISALPHA(c)
|
||||
#define QSE_SCM_ISDIGIT(scm,c) QSE_ISDIGIT(c)
|
||||
#define QSE_SCM_ISXDIGIT(scm,c) QSE_ISXDIGIT(c)
|
||||
#define QSE_SCM_ISALNUM(scm,c) QSE_ISALNUM(c)
|
||||
#define QSE_SCM_ISSPACE(scm,c) QSE_ISSPACE(c)
|
||||
#define QSE_SCM_ISPRINT(scm,c) QSE_ISPRINT(c)
|
||||
#define QSE_SCM_ISGRAPH(scm,c) QSE_ISGRAPH(c)
|
||||
#define QSE_SCM_ISCNTRL(scm,c) QSE_ISCNTRL(c)
|
||||
#define QSE_SCM_ISPUNCT(scm,c) QSE_ISPUNCT(c)
|
||||
#define QSE_SCM_TOUPPER(scm,c) QSE_TOUPPER(c)
|
||||
#define QSE_SCM_TOLOWER(scm,c) QSE_TOLOWER(c)
|
||||
|
||||
struct qse_scm_t
|
||||
{
|
||||
QSE_DEFINE_COMMON_FIELDS (scm)
|
||||
|
||||
qse_scm_prm_t prm;
|
||||
int opt_undef_symbol;
|
||||
|
||||
/** error information */
|
||||
struct
|
||||
{
|
||||
qse_scm_errstr_t str; /**< error string getter */
|
||||
qse_scm_errnum_t num; /**< stores an error number */
|
||||
qse_char_t msg[128]; /**< error message holder */
|
||||
qse_scm_loc_t loc; /**< location of the last error */
|
||||
} err;
|
||||
|
||||
/** memory manager */
|
||||
qse_scm_mem_t mem;
|
||||
|
||||
/** I/O functions */
|
||||
struct
|
||||
{
|
||||
qse_scm_io_t fns;
|
||||
|
||||
struct
|
||||
{
|
||||
qse_scm_io_arg_t in;
|
||||
qse_scm_io_arg_t out;
|
||||
} arg;
|
||||
} io;
|
||||
|
||||
/** data for reading */
|
||||
struct
|
||||
{
|
||||
qse_cint_t curc;
|
||||
qse_scm_loc_t curloc;
|
||||
|
||||
/** token */
|
||||
struct
|
||||
{
|
||||
int type;
|
||||
qse_scm_loc_t loc;
|
||||
qse_long_t ival;
|
||||
qse_real_t rval;
|
||||
qse_str_t name;
|
||||
} t;
|
||||
} r;
|
||||
|
||||
/** data for evaluation */
|
||||
/*
|
||||
struct
|
||||
{
|
||||
} e;
|
||||
*/
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* err.c */
|
||||
const qse_char_t* qse_scm_dflerrstr (qse_scm_t* scm, qse_scm_errnum_t errnum);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
Loading…
x
Reference in New Issue
Block a user