experimental code for better module handling

This commit is contained in:
hyunghwan.chung
2016-11-18 18:11:13 +00:00
parent dab3423f12
commit eaa9dbc958
21 changed files with 1314 additions and 323 deletions

View File

@ -74,29 +74,6 @@ if ENABLE_STATIC_MODULE
# mod-dir.c mod-dir.h \
#libstix_la_LIBADD +=
else
##################################################
# DYNAMIC MODULES
##################################################
CPPFLAGS_MOD_COMMON = $(CPPFLAGS_LIB_COMMON)
LDFLAGS_MOD_COMMON = $(LDFLAGS_LIB_COMMON)
LIBADD_MOD_COMMON = -lstix
pkgmodexecdir = $(libdir)
pkgmodexec_LTLIBRARIES = libstix-snd.la libstix-con.la
libstix_snd_la_SOURCES = mod-snd.c mod-snd.h
libstix_snd_la_CPPFLAGS = $(CPPFLAGS_MOD_COMMON)
libstix_snd_la_LDFLAGS = $(LDFLAGS_MOD_COMMON)
libstix_snd_la_LIBADD = $(LIBADD_MOD_COMMON)
libstix_con_la_SOURCES = mod-con.c mod-con.h
libstix_con_la_CPPFLAGS = $(CPPFLAGS_MOD_COMMON)
libstix_con_la_LDFLAGS = $(LDFLAGS_MOD_COMMON)
libstix_con_la_LIBADD = $(LIBADD_MOD_COMMON) -ltermcap
endif

View File

@ -128,39 +128,10 @@ am__uninstall_files_from_dir = { \
|| { echo " ( cd '$$dir' && rm -f" $$files ")"; \
$(am__cd) "$$dir" && rm -f $$files; }; \
}
am__installdirs = "$(DESTDIR)$(pkglibdir)" \
"$(DESTDIR)$(pkgmodexecdir)" "$(DESTDIR)$(bindir)" \
am__installdirs = "$(DESTDIR)$(pkglibdir)" "$(DESTDIR)$(bindir)" \
"$(DESTDIR)$(pkgincludedir)"
LTLIBRARIES = $(pkglib_LTLIBRARIES) $(pkgmodexec_LTLIBRARIES)
LTLIBRARIES = $(pkglib_LTLIBRARIES)
am__DEPENDENCIES_1 =
@ENABLE_STATIC_MODULE_FALSE@libstix_con_la_DEPENDENCIES = \
@ENABLE_STATIC_MODULE_FALSE@ $(am__DEPENDENCIES_1)
am__libstix_con_la_SOURCES_DIST = mod-con.c mod-con.h
@ENABLE_STATIC_MODULE_FALSE@am_libstix_con_la_OBJECTS = \
@ENABLE_STATIC_MODULE_FALSE@ libstix_con_la-mod-con.lo
libstix_con_la_OBJECTS = $(am_libstix_con_la_OBJECTS)
AM_V_lt = $(am__v_lt_@AM_V@)
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
am__v_lt_0 = --silent
am__v_lt_1 =
libstix_con_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \
$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \
$(AM_CFLAGS) $(CFLAGS) $(libstix_con_la_LDFLAGS) $(LDFLAGS) -o \
$@
@ENABLE_STATIC_MODULE_FALSE@am_libstix_con_la_rpath = -rpath \
@ENABLE_STATIC_MODULE_FALSE@ $(pkgmodexecdir)
@ENABLE_STATIC_MODULE_FALSE@libstix_snd_la_DEPENDENCIES = \
@ENABLE_STATIC_MODULE_FALSE@ $(am__DEPENDENCIES_1)
am__libstix_snd_la_SOURCES_DIST = mod-snd.c mod-snd.h
@ENABLE_STATIC_MODULE_FALSE@am_libstix_snd_la_OBJECTS = \
@ENABLE_STATIC_MODULE_FALSE@ libstix_snd_la-mod-snd.lo
libstix_snd_la_OBJECTS = $(am_libstix_snd_la_OBJECTS)
libstix_snd_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \
$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \
$(AM_CFLAGS) $(CFLAGS) $(libstix_snd_la_LDFLAGS) $(LDFLAGS) -o \
$@
@ENABLE_STATIC_MODULE_FALSE@am_libstix_snd_la_rpath = -rpath \
@ENABLE_STATIC_MODULE_FALSE@ $(pkgmodexecdir)
am__DEPENDENCIES_2 = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
libstix_la_DEPENDENCIES = $(am__DEPENDENCIES_2)
am_libstix_la_OBJECTS = libstix_la-bigint.lo libstix_la-comp.lo \
@ -170,6 +141,10 @@ am_libstix_la_OBJECTS = libstix_la-bigint.lo libstix_la-comp.lo \
libstix_la-proc.lo libstix_la-rbt.lo libstix_la-stix.lo \
libstix_la-sym.lo libstix_la-utf8.lo libstix_la-utl.lo
libstix_la_OBJECTS = $(am_libstix_la_OBJECTS)
AM_V_lt = $(am__v_lt_@AM_V@)
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
am__v_lt_0 = --silent
am__v_lt_1 =
libstix_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(libstix_la_LDFLAGS) $(LDFLAGS) -o $@
@ -214,11 +189,8 @@ AM_V_CCLD = $(am__v_CCLD_@AM_V@)
am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
am__v_CCLD_0 = @echo " CCLD " $@;
am__v_CCLD_1 =
SOURCES = $(libstix_con_la_SOURCES) $(libstix_snd_la_SOURCES) \
$(libstix_la_SOURCES) $(stix_SOURCES)
DIST_SOURCES = $(am__libstix_con_la_SOURCES_DIST) \
$(am__libstix_snd_la_SOURCES_DIST) $(libstix_la_SOURCES) \
$(stix_SOURCES)
SOURCES = $(libstix_la_SOURCES) $(stix_SOURCES)
DIST_SOURCES = $(libstix_la_SOURCES) $(stix_SOURCES)
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
@ -458,30 +430,6 @@ stix_SOURCES = main.c
stix_CPPFLAGS = $(CPPFLAGS_LIB_COMMON)
stix_LDFLAGS = $(LDFLAGS_LIB_COMMON)
stix_LDADD = $(LIBADD_LIB_COMMON) -lstix #-ldyncall_s
##################################################
# STATIC MODULES BUILT INTO MAIN LIBRARY
##################################################
#libstix_la_SOURCES += \
# mod-dir.c mod-dir.h \
#libstix_la_LIBADD +=
##################################################
# DYNAMIC MODULES
##################################################
@ENABLE_STATIC_MODULE_FALSE@CPPFLAGS_MOD_COMMON = $(CPPFLAGS_LIB_COMMON)
@ENABLE_STATIC_MODULE_FALSE@LDFLAGS_MOD_COMMON = $(LDFLAGS_LIB_COMMON)
@ENABLE_STATIC_MODULE_FALSE@LIBADD_MOD_COMMON = -lstix
@ENABLE_STATIC_MODULE_FALSE@pkgmodexecdir = $(libdir)
@ENABLE_STATIC_MODULE_FALSE@pkgmodexec_LTLIBRARIES = libstix-snd.la libstix-con.la
@ENABLE_STATIC_MODULE_FALSE@libstix_snd_la_SOURCES = mod-snd.c mod-snd.h
@ENABLE_STATIC_MODULE_FALSE@libstix_snd_la_CPPFLAGS = $(CPPFLAGS_MOD_COMMON)
@ENABLE_STATIC_MODULE_FALSE@libstix_snd_la_LDFLAGS = $(LDFLAGS_MOD_COMMON)
@ENABLE_STATIC_MODULE_FALSE@libstix_snd_la_LIBADD = $(LIBADD_MOD_COMMON)
@ENABLE_STATIC_MODULE_FALSE@libstix_con_la_SOURCES = mod-con.c mod-con.h
@ENABLE_STATIC_MODULE_FALSE@libstix_con_la_CPPFLAGS = $(CPPFLAGS_MOD_COMMON)
@ENABLE_STATIC_MODULE_FALSE@libstix_con_la_LDFLAGS = $(LDFLAGS_MOD_COMMON)
@ENABLE_STATIC_MODULE_FALSE@libstix_con_la_LIBADD = $(LIBADD_MOD_COMMON) -ltermcap
all: stix-cfg.h
$(MAKE) $(AM_MAKEFLAGS) all-am
@ -568,47 +516,6 @@ clean-pkglibLTLIBRARIES:
rm -f $${locs}; \
}
install-pkgmodexecLTLIBRARIES: $(pkgmodexec_LTLIBRARIES)
@$(NORMAL_INSTALL)
@list='$(pkgmodexec_LTLIBRARIES)'; test -n "$(pkgmodexecdir)" || list=; \
list2=; for p in $$list; do \
if test -f $$p; then \
list2="$$list2 $$p"; \
else :; fi; \
done; \
test -z "$$list2" || { \
echo " $(MKDIR_P) '$(DESTDIR)$(pkgmodexecdir)'"; \
$(MKDIR_P) "$(DESTDIR)$(pkgmodexecdir)" || exit 1; \
echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(pkgmodexecdir)'"; \
$(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(pkgmodexecdir)"; \
}
uninstall-pkgmodexecLTLIBRARIES:
@$(NORMAL_UNINSTALL)
@list='$(pkgmodexec_LTLIBRARIES)'; test -n "$(pkgmodexecdir)" || list=; \
for p in $$list; do \
$(am__strip_dir) \
echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkgmodexecdir)/$$f'"; \
$(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkgmodexecdir)/$$f"; \
done
clean-pkgmodexecLTLIBRARIES:
-test -z "$(pkgmodexec_LTLIBRARIES)" || rm -f $(pkgmodexec_LTLIBRARIES)
@list='$(pkgmodexec_LTLIBRARIES)'; \
locs=`for p in $$list; do echo $$p; done | \
sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \
sort -u`; \
test -z "$$locs" || { \
echo rm -f $${locs}; \
rm -f $${locs}; \
}
libstix-con.la: $(libstix_con_la_OBJECTS) $(libstix_con_la_DEPENDENCIES) $(EXTRA_libstix_con_la_DEPENDENCIES)
$(AM_V_CCLD)$(libstix_con_la_LINK) $(am_libstix_con_la_rpath) $(libstix_con_la_OBJECTS) $(libstix_con_la_LIBADD) $(LIBS)
libstix-snd.la: $(libstix_snd_la_OBJECTS) $(libstix_snd_la_DEPENDENCIES) $(EXTRA_libstix_snd_la_DEPENDENCIES)
$(AM_V_CCLD)$(libstix_snd_la_LINK) $(am_libstix_snd_la_rpath) $(libstix_snd_la_OBJECTS) $(libstix_snd_la_LIBADD) $(LIBS)
libstix.la: $(libstix_la_OBJECTS) $(libstix_la_DEPENDENCIES) $(EXTRA_libstix_la_DEPENDENCIES)
$(AM_V_CCLD)$(libstix_la_LINK) -rpath $(pkglibdir) $(libstix_la_OBJECTS) $(libstix_la_LIBADD) $(LIBS)
install-binPROGRAMS: $(bin_PROGRAMS)
@ -671,7 +578,6 @@ mostlyclean-compile:
distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libstix_con_la-mod-con.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libstix_la-bigint.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libstix_la-comp.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libstix_la-debug.Plo@am__quote@
@ -689,7 +595,6 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libstix_la-sym.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libstix_la-utf8.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libstix_la-utl.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libstix_snd_la-mod-snd.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stix-main.Po@am__quote@
.c.o:
@ -716,20 +621,6 @@ distclean-compile:
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
libstix_con_la-mod-con.lo: mod-con.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libstix_con_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libstix_con_la-mod-con.lo -MD -MP -MF $(DEPDIR)/libstix_con_la-mod-con.Tpo -c -o libstix_con_la-mod-con.lo `test -f 'mod-con.c' || echo '$(srcdir)/'`mod-con.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libstix_con_la-mod-con.Tpo $(DEPDIR)/libstix_con_la-mod-con.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mod-con.c' object='libstix_con_la-mod-con.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libstix_con_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libstix_con_la-mod-con.lo `test -f 'mod-con.c' || echo '$(srcdir)/'`mod-con.c
libstix_snd_la-mod-snd.lo: mod-snd.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libstix_snd_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libstix_snd_la-mod-snd.lo -MD -MP -MF $(DEPDIR)/libstix_snd_la-mod-snd.Tpo -c -o libstix_snd_la-mod-snd.lo `test -f 'mod-snd.c' || echo '$(srcdir)/'`mod-snd.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libstix_snd_la-mod-snd.Tpo $(DEPDIR)/libstix_snd_la-mod-snd.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='mod-snd.c' object='libstix_snd_la-mod-snd.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libstix_snd_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libstix_snd_la-mod-snd.lo `test -f 'mod-snd.c' || echo '$(srcdir)/'`mod-snd.c
libstix_la-bigint.lo: bigint.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libstix_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libstix_la-bigint.lo -MD -MP -MF $(DEPDIR)/libstix_la-bigint.Tpo -c -o libstix_la-bigint.lo `test -f 'bigint.c' || echo '$(srcdir)/'`bigint.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libstix_la-bigint.Tpo $(DEPDIR)/libstix_la-bigint.Plo
@ -976,7 +867,7 @@ check-am: all-am
check: check-am
all-am: Makefile $(LTLIBRARIES) $(PROGRAMS) $(HEADERS) stix-cfg.h
installdirs:
for dir in "$(DESTDIR)$(pkglibdir)" "$(DESTDIR)$(pkgmodexecdir)" "$(DESTDIR)$(bindir)" "$(DESTDIR)$(pkgincludedir)"; do \
for dir in "$(DESTDIR)$(pkglibdir)" "$(DESTDIR)$(bindir)" "$(DESTDIR)$(pkgincludedir)"; do \
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
done
install: install-am
@ -1012,8 +903,7 @@ maintainer-clean-generic:
clean: clean-am
clean-am: clean-binPROGRAMS clean-generic clean-libtool \
clean-pkglibLTLIBRARIES clean-pkgmodexecLTLIBRARIES \
mostlyclean-am
clean-pkglibLTLIBRARIES mostlyclean-am
distclean: distclean-am
-rm -rf ./$(DEPDIR)
@ -1040,8 +930,7 @@ install-dvi: install-dvi-am
install-dvi-am:
install-exec-am: install-binPROGRAMS install-pkglibLTLIBRARIES \
install-pkgmodexecLTLIBRARIES
install-exec-am: install-binPROGRAMS install-pkglibLTLIBRARIES
install-html: install-html-am
@ -1082,32 +971,37 @@ ps: ps-am
ps-am:
uninstall-am: uninstall-binPROGRAMS uninstall-pkgincludeHEADERS \
uninstall-pkglibLTLIBRARIES uninstall-pkgmodexecLTLIBRARIES
uninstall-pkglibLTLIBRARIES
@$(NORMAL_INSTALL)
$(MAKE) $(AM_MAKEFLAGS) uninstall-hook
.MAKE: all install-am install-data-am install-strip uninstall-am
.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean \
clean-binPROGRAMS clean-generic clean-libtool \
clean-pkglibLTLIBRARIES clean-pkgmodexecLTLIBRARIES \
cscopelist-am ctags ctags-am distclean distclean-compile \
distclean-generic distclean-hdr distclean-libtool \
distclean-tags distdir dvi dvi-am html html-am info info-am \
install install-am install-binPROGRAMS install-data \
install-data-am install-data-hook install-dvi install-dvi-am \
install-exec install-exec-am install-html install-html-am \
install-info install-info-am install-man install-pdf \
install-pdf-am install-pkgincludeHEADERS \
install-pkglibLTLIBRARIES install-pkgmodexecLTLIBRARIES \
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 tags-am uninstall uninstall-am uninstall-binPROGRAMS \
uninstall-hook uninstall-pkgincludeHEADERS \
uninstall-pkglibLTLIBRARIES uninstall-pkgmodexecLTLIBRARIES
clean-pkglibLTLIBRARIES cscopelist-am ctags ctags-am distclean \
distclean-compile distclean-generic distclean-hdr \
distclean-libtool distclean-tags distdir dvi dvi-am html \
html-am info info-am install install-am install-binPROGRAMS \
install-data install-data-am install-data-hook install-dvi \
install-dvi-am install-exec install-exec-am install-html \
install-html-am install-info install-info-am install-man \
install-pdf install-pdf-am install-pkgincludeHEADERS \
install-pkglibLTLIBRARIES 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 tags-am uninstall uninstall-am \
uninstall-binPROGRAMS uninstall-hook \
uninstall-pkgincludeHEADERS uninstall-pkglibLTLIBRARIES
##################################################
# STATIC MODULES BUILT INTO MAIN LIBRARY
##################################################
#libstix_la_SOURCES += \
# mod-dir.c mod-dir.h \
#libstix_la_LIBADD +=
install-data-hook:
@echo "#ifndef _STIX_CFG_H_" > "$(DESTDIR)$(pkgincludedir)/stix-cfg.h"
@echo "#define _STIX_CFG_H_" >> "$(DESTDIR)$(pkgincludedir)/stix-cfg.h"

View File

@ -2477,6 +2477,20 @@ static int compile_class_level_variables (stix_t* stix)
{
var_info_t var;
/*
TODO: check variability conflict.
if it's a indexed class, check if the superclass is fixed or index.
if super is fixed and self is fixed or variable-pointer, no restriction.
if super is fixed and self is variable-nonpointer, no instance varaible in the super side and in the self side.
if super is variable-pointer, self must be a variable-pointer. can't be fixed either
if super is variable-nonpointer, self must be a variable-nonpointer of the same type. can't be fixed either
if super is variable-nonpointer, no instance variable is allowed.
if (stix->c->cls.flags & CLASS_INDEXED)
{
set_syntax_error (stix, STIX_SYNERR_VARNAMEDUP, TOKEN_LOC(stix), TOKEN_NAME(stix));
return -1;
}
*/
if (find_class_level_variable(stix, STIX_NULL, TOKEN_NAME(stix), &var) >= 0 ||
stix_lookupdic (stix, stix->sysdic, TOKEN_NAME(stix)) || /* conflicts with a top global name */
stix_lookupdic (stix, stix->c->cls.ns_oop, TOKEN_NAME(stix))) /* conflicts with a global name in the class'es name space */

View File

@ -1,340 +0,0 @@
/*
* $Id$
*
Copyright (c) 2014-2016 Chung, Hyung-Hwan. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "mod-con.h"
#include <stix-utl.h>
#include "stix-prv.h" /* TODO: remove this header after refactoring it */
#include <unistd.h>
#include <fcntl.h>
#include <stdlib.h> /* getenv */
#include <curses.h>
#include <term.h>
#include <sys/ioctl.h>
typedef struct console_t console_t;
struct console_t
{
int fd;
int fd_opened;
char* cup;
char* clear;
};
/* ------------------------------------------------------------------------ */
static int prim_open (stix_t* stix, stix_ooi_t nargs)
{
#if defined(_WIN32)
HANDLE h;
stix_ooi_t immv;
h = GetStdHandle(STD_INPUT_HANDLE);
if (h == INVALID_HANDLE_VALUE) return 0;
if (h == NULL)
{
}
imm = stix_makeimm (stix, h);
if (imm <= -1)
{
/* error */
}
rsrc = stix_makersrc (stix, h);
#else
console_t* con;
int err;
char* term;
con = stix_callocmem (stix, STIX_SIZEOF(*con));
if (!con) return 0;
if (isatty(1))
{
con->fd = 1;
}
else
{
con->fd = open ("/dev/tty", O_RDWR, 0);
if (con->fd == -1)
{
/* TODO: failed to open /dev/stdout */
stix_freemem (stix, con);
return 0;
}
con->fd_opened = 1;
}
term = getenv ("TERM");
if (term && setupterm (term, con->fd, &err) == OK)
{
}
con->cup = tigetstr ("cup"); /* TODO: error check */
con->clear = tigetstr ("clear");
#if 0
{
const char* cup, * clear;
struct winsize wsz;
cup = tigetstr ("cup");
clear = tigetstr ("clear");
ioctl (fd, TIOCGWINSZ, &wsz);
write (fd, clear, strlen(clear));
/*write (fd, tparm (cup, wsz.ws_row - 1, 0), strlen(tparm (cup, wsz.ws_row - 1, 0)));*/
write (fd, tiparm (cup, 0, 0), strlen(tiparm (cup, 0, 0)));
}
#endif
#endif
STIX_STACK_SETRET (stix, nargs, STIX_SMOOI_TO_OOP((stix_oow_t)con));
return 1;
}
static int prim_close (stix_t* stix, stix_ooi_t nargs)
{
#if defined(_WIN32)
HANDLE h;
h = STIX_STACK_GETARG (stix, nargs, 0);
#else
#endif
console_t* con;
con = STIX_OOP_TO_SMOOI(STIX_STACK_GETARG (stix, nargs, 0));
/* TODO: sanity check */
if (con->fd_opened) close (con->fd);
STIX_STACK_SETRETTORCV (stix, nargs);
return 1;
}
static int prim_write (stix_t* stix, stix_ooi_t nargs)
{
console_t* con;
stix_oop_char_t oomsg;
stix_oow_t ucspos, ucsrem, ucslen, bcslen;
stix_bch_t bcs[1024];
int n;
con = STIX_OOP_TO_SMOOI(STIX_STACK_GETARG (stix, nargs, 0));
oomsg = (stix_oop_char_t)STIX_STACK_GETARG (stix, nargs, 1);
if (STIX_CLASSOF(stix,oomsg) != stix->_string)
{
/* TODO: invalid message */
return 0;
}
ucspos = 0;
ucsrem = STIX_OBJ_GET_SIZE(oomsg);
while (ucsrem > 0)
{
ucslen = ucsrem;
bcslen = STIX_COUNTOF(bcs);
if ((n = stix_ucstoutf8 (&oomsg->slot[ucspos], &ucslen, bcs, &bcslen)) <= -1)
{
if (n != -2 || ucslen <= 0)
{
stix_seterrnum (stix, STIX_EECERR);
return -1;
}
}
write (con->fd, bcs, bcslen); /* TODO: error handling */
/* TODO: abort looping for async processing???? */
ucspos += ucslen;
ucsrem -= ucslen;
}
STIX_STACK_SETRETTORCV (stix, nargs); /* TODO: change return code */
return 1;
}
static int prim_clear (stix_t* stix, stix_ooi_t nargs)
{
console_t* con;
con = STIX_OOP_TO_SMOOI(STIX_STACK_GETARG(stix, nargs, 0));
write (con->fd, con->clear, strlen(con->clear));
STIX_STACK_SETRETTORCV (stix, nargs);
return 1;
}
static int prim_setcursor (stix_t* stix, stix_ooi_t nargs)
{
console_t* con;
stix_oop_oop_t point;
char* cup;
con = STIX_OOP_TO_SMOOI(STIX_STACK_GETARG(stix, nargs, 0));
point = STIX_STACK_GETARG(stix, nargs, 1);
/* TODO: error check, class check, size check.. */
if (STIX_OBJ_GET_SIZE(point) != 2)
{
return 0;
}
cup = tiparm (con->cup, STIX_OOP_TO_SMOOI(point->slot[1]), STIX_OOP_TO_SMOOI(point->slot[0]));
write (con->fd, cup, strlen(cup)); /* TODO: error check */
STIX_STACK_SETRETTORCV (stix, nargs);
return 1;
}
#if 0
static int prim_setcursorto (stix_t* stix, stix_ooi_t nargs)
{
console_t* con;
stix_oop_oop_t point;
char* cup;
rcv = STIX_STACK_GETRCV(stix, nargs);
con = STIX_OOP_TO_SMOOI(
con = STIX_OOP_TO_SMOOI(STIX_STACK_GETARG(stix, nargs, 0));
point = STIX_STACK_GETARG(stix, nargs, 1);
/* TODO: error check, class check, size check.. */
if (STIX_OBJ_GET_SIZE(point) != 2)
{
return 0;
}
cup = tiparm (con->cup, STIX_OOP_TO_SMOOI(point->slot[1]), STIX_OOP_TO_SMOOI(point->slot[0]));
write (con->fd, cup, strlen(cup)); /* TODO: error check */
STIX_STACK_SETRETTORCV (stix, nargs);
return 1;
}
#endif
/* ------------------------------------------------------------------------ */
typedef struct fnctab_t fnctab_t;
struct fnctab_t
{
const stix_bch_t* name;
stix_prim_impl_t handler;
};
static fnctab_t fnctab[] =
{
{ "clear", prim_clear },
{ "close", prim_close },
{ "open", prim_open },
{ "setcursor", prim_setcursor },
{ "write", prim_write },
};
/* ------------------------------------------------------------------------ */
static stix_prim_impl_t query (stix_t* stix, stix_prim_mod_t* mod, const stix_ooch_t* name)
{
int left, right, mid, n;
left = 0; right = STIX_COUNTOF(fnctab) - 1;
while (left <= right)
{
mid = (left + right) / 2;
n = stix_compoocbcstr (name, fnctab[mid].name);
if (n < 0) right = mid - 1;
else if (n > 0) left = mid + 1;
else
{
return fnctab[mid].handler;
}
}
stix->errnum = STIX_ENOENT;
return STIX_NULL;
}
static void unload (stix_t* stix, stix_prim_mod_t* mod)
{
/* TODO: close all open handle?? */
}
int stix_prim_mod_con (stix_t* stix, stix_prim_mod_t* mod)
{
mod->query = query;
mod->unload = unload;
mod->ctx = STIX_NULL;
#if 0
#include 'Stix.st'.
#import 'Console'.
c = stix_findclass (stix, "Console");
if (!c) c = stix_makeclass (stix, "Console", "x y"); <- provides an API to create a simple class
stix_addmethod (stix, c, "open", prim_open);
stix_addmethod (stix, c, "close:", prim_close);
stix_addmethod (stix, c, "setCursorTo:", prim_setcursor);
stix_addmethod (stix, c, "clear", prim_clear );
stix_addmethod (stix, c, "write", prim_write );
/* GRAMMER ENHANCEMENT */
fun abc (a, b, c) <----- this style, register C style method
{
}
fun abc: a with: b c: c <----- smalltalk style
{
}
abc->def (a, b, c) <------- use -> as an c style method indicator
abc abc: a with: b c: c
#endif
return 0;
}

View File

@ -1,102 +0,0 @@
/*
* $Id$
*
Copyright (c) 2014-2016 Chung, Hyung-Hwan. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "mod-snd.h"
#include <stix-utl.h>
/* ------------------------------------------------------------------------ */
static int prim_open (stix_t* stix, stix_ooi_t nargs)
{
printf ("<<<<<<<<<<<SND OPEN>>>>>>>>>>>>>>>>>>\n");
STIX_STACK_POPS (stix, nargs);
return 1;
}
static int prim_close (stix_t* stix, stix_ooi_t nargs)
{
printf ("<<<<<<<<<<<<<<<<<<<<SND CLOSE>>>>>>>>>>>>>>>>>>>>>>\n");
STIX_STACK_POPS (stix, nargs);
return 1;
}
typedef struct fnctab_t fnctab_t;
struct fnctab_t
{
const stix_bch_t* name;
stix_prim_impl_t handler;
};
static fnctab_t fnctab[] =
{
{ "close", prim_close },
{ "open", prim_open }
};
/* ------------------------------------------------------------------------ */
static stix_prim_impl_t query (stix_t* stix, stix_prim_mod_t* mod, const stix_ooch_t* name)
{
int left, right, mid, n;
left = 0; right = STIX_COUNTOF(fnctab) - 1;
while (left <= right)
{
mid = (left + right) / 2;
n = stix_compoocbcstr (name, fnctab[mid].name);
if (n < 0) right = mid - 1;
else if (n > 0) left = mid + 1;
else
{
return fnctab[mid].handler;
}
}
/*
ea.ptr = (stix_char_t*)name;
ea.len = stix_strlen(name);
stix_seterror (stix, STIX_ENOENT, &ea, QSE_NULL);
*/
return STIX_NULL;
}
static void unload (stix_t* stix, stix_prim_mod_t* mod)
{
}
int stix_prim_mod_snd (stix_t* stix, stix_prim_mod_t* mod)
{
mod->query = query;
mod->unload = unload;
mod->ctx = STIX_NULL;
return 0;
}

View File

@ -1,43 +0,0 @@
/*
* $Id$
*
Copyright (c) 2006-2016 Chung, Hyung-Hwan. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _STIX_LIB_MOD_SND_H_
#define _STIX_LIB_MOD_SND_H_
#include <stix.h>
#if defined(__cplusplus)
extern "C" {
#endif
STIX_EXPORT int stix_prim_mod_snd (stix_t* stix, stix_prim_mod_t* mod);
#if defined(__cplusplus)
}
#endif
#endif

View File

@ -189,9 +189,14 @@ static STIX_INLINE int decode_spec (stix_t* stix, stix_oop_t _class, stix_oow_t
if (indexed_type == STIX_OBJ_TYPE_OOP)
{
if (named_instvar > STIX_MAX_NAMED_INSTVARS ||
vlen > STIX_MAX_INDEXED_INSTVARS(named_instvar))
if (named_instvar > STIX_MAX_NAMED_INSTVARS)
{
STIX_DEBUG3 (stix, "Too many named instance variables for a variable-pointer class %O - %zu/%zu\n", _class, named_instvar, (stix_oow_t)STIX_MAX_NAMED_INSTVARS);
return -1;
}
if (vlen > STIX_MAX_INDEXED_INSTVARS(named_instvar))
{
STIX_DEBUG3 (stix, "Too many unnamed instance variables for a variable-pointer class %O - %zu/%zu\n", _class, vlen, (stix_oow_t)STIX_MAX_INDEXED_INSTVARS(named_instvar));
return -1;
}
@ -200,8 +205,16 @@ static STIX_INLINE int decode_spec (stix_t* stix, stix_oop_t _class, stix_oow_t
else
{
/* a non-pointer indexed class can't have named instance variables */
if (named_instvar > 0) return -1;
if (vlen > STIX_OBJ_SIZE_MAX) return -1;
if (named_instvar > 0)
{
STIX_DEBUG1 (stix, "Named instance variables in a variable-nonpointer class %O\n", _class);
return -1;
}
if (vlen > STIX_OBJ_SIZE_MAX)
{
STIX_DEBUG3 (stix, "Too many unnamed instance variables for a variable-nonpointer class %O - %zu/%zu\n", _class, vlen, (stix_oow_t)STIX_OBJ_SIZE_MAX);
return -1;
}
}
}
else
@ -209,9 +222,19 @@ static STIX_INLINE int decode_spec (stix_t* stix, stix_oop_t _class, stix_oow_t
/* named instance variables only. treat it as if it is an
* indexable class with no variable data */
indexed_type = STIX_OBJ_TYPE_OOP;
vlen = 0; /* vlen is not used */
if (named_instvar > STIX_MAX_NAMED_INSTVARS) return -1;
if (vlen > 0)
{
STIX_DEBUG2 (stix, "Unamed instance variables for a fixed class %O - %zu\n", _class, vlen);
return -1;
}
/*vlen = 0;*/ /* vlen is not used */
if (named_instvar > STIX_MAX_NAMED_INSTVARS)
{
STIX_DEBUG3 (stix, "Too many named instance variables for a fixed class %O - %zu/%zu\n", _class, named_instvar, (stix_oow_t)STIX_MAX_NAMED_INSTVARS);
return -1;
}
STIX_ASSERT (named_instvar <= STIX_OBJ_SIZE_MAX);
}

View File

@ -1085,91 +1085,6 @@ stix_oop_process_t stix_makeproc (
stix_t* stix
);
/* ========================================================================= */
/* utf8.c */
/* ========================================================================= */
stix_oow_t stix_uctoutf8 (
stix_uch_t uc,
stix_bch_t* utf8,
stix_oow_t size
);
stix_oow_t stix_utf8touc (
const stix_bch_t* utf8,
stix_oow_t size,
stix_uch_t* uc
);
/**
* The stix_ucstoutf8() function converts a unicode character string \a ucs
* to a UTF8 string and writes it into the buffer pointed to by \a bcs, but
* not more than \a bcslen bytes including the terminating null.
*
* Upon return, \a bcslen is modified to the actual number of bytes written to
* \a bcs excluding the terminating null; \a ucslen is modified to the number of
* wide characters converted.
*
* You may pass #STIX_NULL for \a bcs to dry-run conversion or to get the
* required buffer size for conversion. -2 is never returned in this case.
*
* \return
* - 0 on full conversion,
* - -1 on no or partial conversion for an illegal character encountered,
* - -2 on no or partial conversion for a small buffer.
*
* \code
* const stix_uch_t ucs[] = { 'H', 'e', 'l', 'l', 'o' };
* stix_bch_t bcs[10];
* stix_oow_t ucslen = 5;
* stix_oow_t bcslen = STIX_COUNTOF(bcs);
* n = stix_ucstoutf8 (ucs, &ucslen, bcs, &bcslen);
* if (n <= -1)
* {
* // conversion error
* }
* \endcode
*/
int stix_ucstoutf8 (
const stix_uch_t* ucs,
stix_oow_t* ucslen,
stix_bch_t* bcs,
stix_oow_t* bcslen
);
/**
* The stix_utf8toucs() function converts a UTF8 string to a uncide string.
*
* It never returns -2 if \a ucs is #STIX_NULL.
*
* \code
* const stix_bch_t* bcs = "test string";
* stix_uch_t ucs[100];
* stix_oow_t ucslen = STIX_COUNTOF(buf), n;
* stix_oow_t bcslen = 11;
* int n;
* n = stix_utf8toucs (bcs, &bcslen, ucs, &ucslen);
* if (n <= -1) { invalid/incomplenete sequence or buffer to small }
* \endcode
*
* For a null-terminated string, you can specify ~(stix_oow_t)0 in
* \a bcslen. The destination buffer \a ucs also must be large enough to
* store a terminating null. Otherwise, -2 is returned.
*
* The resulting \a ucslen can still be greater than 0 even if the return
* value is negative. The value indiates the number of characters converted
* before the error has occurred.
*
* \return 0 on success.
* -1 if \a bcs contains an illegal character.
* -2 if the wide-character string buffer is too small.
* -3 if \a bcs is not a complete sequence.
*/
int stix_utf8toucs (
const stix_bch_t* bcs,
stix_oow_t* bcslen,
stix_uch_t* ucs,
stix_oow_t* ucslen
);
/* ========================================================================= */
/* bigint.c */

View File

@ -57,12 +57,12 @@ extern "C" {
/* ========================================================================= */
/* utl.c */
/* ========================================================================= */
stix_oow_t stix_hashbytes (
STIX_EXPORT stix_oow_t stix_hashbytes (
const stix_oob_t* ptr,
stix_oow_t len
);
stix_oow_t stix_hashuchars (
STIX_EXPORT stix_oow_t stix_hashuchars (
const stix_uch_t* ptr,
stix_oow_t len
);
@ -70,84 +70,171 @@ stix_oow_t stix_hashuchars (
#define stix_hashbchars(ptr,len) stix_hashbytes(ptr,len)
int stix_equalchars (
STIX_EXPORT int stix_equalchars (
const stix_uch_t* str1,
const stix_uch_t* str2,
stix_oow_t len
);
int stix_compucstr (
STIX_EXPORT int stix_compucstr (
const stix_uch_t* str1,
const stix_uch_t* str2
);
int stix_compbcstr (
STIX_EXPORT int stix_compbcstr (
const stix_bch_t* str1,
const stix_bch_t* str2
);
int stix_compucbcstr (
STIX_EXPORT int stix_compucbcstr (
const stix_uch_t* str1,
const stix_bch_t* str2
);
int stix_compucxbcstr (
STIX_EXPORT int stix_compucxbcstr (
const stix_uch_t* str1,
stix_oow_t len,
const stix_bch_t* str2
);
void stix_copyuchars (
STIX_EXPORT void stix_copyuchars (
stix_uch_t* dst,
const stix_uch_t* src,
stix_oow_t len
);
void stix_copybchars (
STIX_EXPORT void stix_copybchars (
stix_bch_t* dst,
const stix_bch_t* src,
stix_oow_t len
);
void stix_copybchtouchars (
STIX_EXPORT void stix_copybchtouchars (
stix_uch_t* dst,
const stix_bch_t* src,
stix_oow_t len
);
stix_oow_t stix_copyucstr (
STIX_EXPORT stix_oow_t stix_copyucstr (
stix_uch_t* dst,
stix_oow_t len,
const stix_uch_t* src
);
stix_oow_t stix_copybcstr (
STIX_EXPORT stix_oow_t stix_copybcstr (
stix_bch_t* dst,
stix_oow_t len,
const stix_bch_t* src
);
stix_uch_t* stix_finduchar (
STIX_EXPORT stix_uch_t* stix_finduchar (
const stix_uch_t* ptr,
stix_oow_t len,
stix_uch_t c
);
stix_bch_t* stix_findbchar (
STIX_EXPORT stix_bch_t* stix_findbchar (
const stix_bch_t* ptr,
stix_oow_t len,
stix_bch_t c
);
stix_oow_t stix_countucstr (
STIX_EXPORT stix_oow_t stix_countucstr (
const stix_uch_t* str
);
stix_oow_t stix_countbcstr (
STIX_EXPORT stix_oow_t stix_countbcstr (
const stix_bch_t* str
);
/* ========================================================================= */
/* utf8.c */
/* ========================================================================= */
STIX_EXPORT stix_oow_t stix_uctoutf8 (
stix_uch_t uc,
stix_bch_t* utf8,
stix_oow_t size
);
STIX_EXPORT stix_oow_t stix_utf8touc (
const stix_bch_t* utf8,
stix_oow_t size,
stix_uch_t* uc
);
/**
* The stix_ucstoutf8() function converts a unicode character string \a ucs
* to a UTF8 string and writes it into the buffer pointed to by \a bcs, but
* not more than \a bcslen bytes including the terminating null.
*
* Upon return, \a bcslen is modified to the actual number of bytes written to
* \a bcs excluding the terminating null; \a ucslen is modified to the number of
* wide characters converted.
*
* You may pass #STIX_NULL for \a bcs to dry-run conversion or to get the
* required buffer size for conversion. -2 is never returned in this case.
*
* \return
* - 0 on full conversion,
* - -1 on no or partial conversion for an illegal character encountered,
* - -2 on no or partial conversion for a small buffer.
*
* \code
* const stix_uch_t ucs[] = { 'H', 'e', 'l', 'l', 'o' };
* stix_bch_t bcs[10];
* stix_oow_t ucslen = 5;
* stix_oow_t bcslen = STIX_COUNTOF(bcs);
* n = stix_ucstoutf8 (ucs, &ucslen, bcs, &bcslen);
* if (n <= -1)
* {
* // conversion error
* }
* \endcode
*/
STIX_EXPORT int stix_ucstoutf8 (
const stix_uch_t* ucs,
stix_oow_t* ucslen,
stix_bch_t* bcs,
stix_oow_t* bcslen
);
/**
* The stix_utf8toucs() function converts a UTF8 string to a uncide string.
*
* It never returns -2 if \a ucs is #STIX_NULL.
*
* \code
* const stix_bch_t* bcs = "test string";
* stix_uch_t ucs[100];
* stix_oow_t ucslen = STIX_COUNTOF(buf), n;
* stix_oow_t bcslen = 11;
* int n;
* n = stix_utf8toucs (bcs, &bcslen, ucs, &ucslen);
* if (n <= -1) { invalid/incomplenete sequence or buffer to small }
* \endcode
*
* For a null-terminated string, you can specify ~(stix_oow_t)0 in
* \a bcslen. The destination buffer \a ucs also must be large enough to
* store a terminating null. Otherwise, -2 is returned.
*
* The resulting \a ucslen can still be greater than 0 even if the return
* value is negative. The value indiates the number of characters converted
* before the error has occurred.
*
* \return 0 on success.
* -1 if \a bcs contains an illegal character.
* -2 if the wide-character string buffer is too small.
* -3 if \a bcs is not a complete sequence.
*/
STIX_EXPORT int stix_utf8toucs (
const stix_bch_t* bcs,
stix_oow_t* bcslen,
stix_uch_t* ucs,
stix_oow_t* ucslen
);
#if defined(__cplusplus)
}
#endif