removed the arr module
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
e2864bab55
commit
bad79feacb
@ -98,7 +98,6 @@ libhcl_la_LDFLAGS = $(LDFLAGS_LIB_COMMON)
|
||||
libhcl_la_LIBADD = $(LIBADD_LIB_COMMON)
|
||||
|
||||
if ENABLE_STATIC_MODULE
|
||||
libhcl_la_LIBADD += ../mod/libhcl-arr.la
|
||||
libhcl_la_LIBADD += ../mod/libhcl-core.la
|
||||
libhcl_la_LIBADD += ../mod/libhcl-dic.la
|
||||
libhcl_la_LIBADD += ../mod/libhcl-str.la
|
||||
|
@ -92,8 +92,7 @@ host_triplet = @host@
|
||||
@ENABLE_LIBUNWIND_TRUE@am__append_3 = $(UNWIND_LIBS)
|
||||
@MACOSX_TRUE@@WIN32_FALSE@am__append_4 = -DHCL_DEFAULT_PFMODPOSTFIX=\".dylib\"
|
||||
@MACOSX_FALSE@@WIN32_FALSE@am__append_5 = -DHCL_DEFAULT_PFMODPOSTFIX=\".so\"
|
||||
@ENABLE_STATIC_MODULE_TRUE@am__append_6 = ../mod/libhcl-arr.la \
|
||||
@ENABLE_STATIC_MODULE_TRUE@ ../mod/libhcl-core.la \
|
||||
@ENABLE_STATIC_MODULE_TRUE@am__append_6 = ../mod/libhcl-core.la \
|
||||
@ENABLE_STATIC_MODULE_TRUE@ ../mod/libhcl-dic.la \
|
||||
@ENABLE_STATIC_MODULE_TRUE@ ../mod/libhcl-str.la \
|
||||
@ENABLE_STATIC_MODULE_TRUE@ ../mod/libhcl-sys.la
|
||||
|
@ -736,7 +736,6 @@ void hcl_freemem (hcl_t* hcl, void* ptr)
|
||||
|
||||
#if defined(HCL_ENABLE_STATIC_MODULE)
|
||||
|
||||
#include "../mod/_arr.h"
|
||||
#include "../mod/_core.h"
|
||||
#include "../mod/_dic.h"
|
||||
#include "../mod/_str.h"
|
||||
@ -749,7 +748,6 @@ static struct
|
||||
}
|
||||
static_modtab[] =
|
||||
{
|
||||
{ "arr", hcl_mod_arr },
|
||||
{ "core", hcl_mod_core },
|
||||
{ "dic", hcl_mod_dic },
|
||||
{ "str", hcl_mod_str },
|
||||
|
@ -20,7 +20,6 @@ LIBADD_COMMON =
|
||||
|
||||
noinst_LTLIBRARIES =
|
||||
|
||||
noinst_LTLIBRARIES += libhcl-arr.la
|
||||
noinst_LTLIBRARIES += libhcl-core.la
|
||||
noinst_LTLIBRARIES += libhcl-dic.la
|
||||
noinst_LTLIBRARIES += libhcl-str.la
|
||||
@ -37,7 +36,6 @@ LIBADD_COMMON = -lhcl
|
||||
pkgmodexecdir = $(libdir)
|
||||
pkgmodexec_LTLIBRARIES =
|
||||
|
||||
pkgmodexec_LTLIBRARIES += libhcl-arr.la
|
||||
pkgmodexec_LTLIBRARIES += libhcl-core.la
|
||||
pkgmodexec_LTLIBRARIES += libhcl-dic.la
|
||||
pkgmodexec_LTLIBRARIES += libhcl-str.la
|
||||
@ -45,12 +43,6 @@ pkgmodexec_LTLIBRARIES += libhcl-sys.la
|
||||
|
||||
endif
|
||||
|
||||
libhcl_arr_la_SOURCES = arr.c _arr.h
|
||||
libhcl_arr_la_CPPFLAGS = $(CPPFLAGS_COMMON)
|
||||
libhcl_arr_la_CFLAGS = $(CFLAGS_COMMON)
|
||||
libhcl_arr_la_LDFLAGS = $(LDFLAGS_COMMON)
|
||||
libhcl_arr_la_LIBADD = $(LIBADD_COMMON)
|
||||
|
||||
libhcl_core_la_SOURCES = core.c _core.h
|
||||
libhcl_core_la_CPPFLAGS = $(CPPFLAGS_COMMON)
|
||||
libhcl_core_la_CFLAGS = $(CFLAGS_COMMON)
|
||||
|
@ -132,22 +132,13 @@ am__uninstall_files_from_dir = { \
|
||||
am__installdirs = "$(DESTDIR)$(pkgmodexecdir)"
|
||||
LTLIBRARIES = $(noinst_LTLIBRARIES) $(pkgmodexec_LTLIBRARIES)
|
||||
am__DEPENDENCIES_1 =
|
||||
libhcl_arr_la_DEPENDENCIES = $(am__DEPENDENCIES_1)
|
||||
am_libhcl_arr_la_OBJECTS = libhcl_arr_la-arr.lo
|
||||
libhcl_arr_la_OBJECTS = $(am_libhcl_arr_la_OBJECTS)
|
||||
libhcl_core_la_DEPENDENCIES = $(am__DEPENDENCIES_1)
|
||||
am_libhcl_core_la_OBJECTS = libhcl_core_la-core.lo
|
||||
libhcl_core_la_OBJECTS = $(am_libhcl_core_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 =
|
||||
libhcl_arr_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
|
||||
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(libhcl_arr_la_CFLAGS) \
|
||||
$(CFLAGS) $(libhcl_arr_la_LDFLAGS) $(LDFLAGS) -o $@
|
||||
@ENABLE_STATIC_MODULE_FALSE@am_libhcl_arr_la_rpath = -rpath \
|
||||
@ENABLE_STATIC_MODULE_FALSE@ $(pkgmodexecdir)
|
||||
@ENABLE_STATIC_MODULE_TRUE@am_libhcl_arr_la_rpath =
|
||||
libhcl_core_la_DEPENDENCIES = $(am__DEPENDENCIES_1)
|
||||
am_libhcl_core_la_OBJECTS = libhcl_core_la-core.lo
|
||||
libhcl_core_la_OBJECTS = $(am_libhcl_core_la_OBJECTS)
|
||||
libhcl_core_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \
|
||||
$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \
|
||||
$(libhcl_core_la_CFLAGS) $(CFLAGS) $(libhcl_core_la_LDFLAGS) \
|
||||
@ -197,8 +188,7 @@ am__v_at_1 =
|
||||
DEFAULT_INCLUDES =
|
||||
depcomp = $(SHELL) $(top_srcdir)/ac/depcomp
|
||||
am__maybe_remake_depfiles = depfiles
|
||||
am__depfiles_remade = ./$(DEPDIR)/libhcl_arr_la-arr.Plo \
|
||||
./$(DEPDIR)/libhcl_core_la-core.Plo \
|
||||
am__depfiles_remade = ./$(DEPDIR)/libhcl_core_la-core.Plo \
|
||||
./$(DEPDIR)/libhcl_dic_la-dic.Plo \
|
||||
./$(DEPDIR)/libhcl_str_la-str.Plo \
|
||||
./$(DEPDIR)/libhcl_sys_la-sys.Plo
|
||||
@ -221,12 +211,10 @@ 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 = $(libhcl_arr_la_SOURCES) $(libhcl_core_la_SOURCES) \
|
||||
$(libhcl_dic_la_SOURCES) $(libhcl_str_la_SOURCES) \
|
||||
$(libhcl_sys_la_SOURCES)
|
||||
DIST_SOURCES = $(libhcl_arr_la_SOURCES) $(libhcl_core_la_SOURCES) \
|
||||
$(libhcl_dic_la_SOURCES) $(libhcl_str_la_SOURCES) \
|
||||
$(libhcl_sys_la_SOURCES)
|
||||
SOURCES = $(libhcl_core_la_SOURCES) $(libhcl_dic_la_SOURCES) \
|
||||
$(libhcl_str_la_SOURCES) $(libhcl_sys_la_SOURCES)
|
||||
DIST_SOURCES = $(libhcl_core_la_SOURCES) $(libhcl_dic_la_SOURCES) \
|
||||
$(libhcl_str_la_SOURCES) $(libhcl_sys_la_SOURCES)
|
||||
am__can_run_installinfo = \
|
||||
case $$AM_UPDATE_INFO_DIR in \
|
||||
n|no|NO) false;; \
|
||||
@ -411,18 +399,13 @@ CFLAGS_COMMON =
|
||||
@ENABLE_STATIC_MODULE_TRUE@LDFLAGS_COMMON = -L$(libdir)
|
||||
@ENABLE_STATIC_MODULE_FALSE@LIBADD_COMMON = -lhcl
|
||||
@ENABLE_STATIC_MODULE_TRUE@LIBADD_COMMON =
|
||||
@ENABLE_STATIC_MODULE_TRUE@noinst_LTLIBRARIES = libhcl-arr.la \
|
||||
@ENABLE_STATIC_MODULE_TRUE@ libhcl-core.la libhcl-dic.la \
|
||||
@ENABLE_STATIC_MODULE_TRUE@ libhcl-str.la libhcl-sys.la
|
||||
@ENABLE_STATIC_MODULE_TRUE@noinst_LTLIBRARIES = libhcl-core.la \
|
||||
@ENABLE_STATIC_MODULE_TRUE@ libhcl-dic.la libhcl-str.la \
|
||||
@ENABLE_STATIC_MODULE_TRUE@ libhcl-sys.la
|
||||
@ENABLE_STATIC_MODULE_FALSE@pkgmodexecdir = $(libdir)
|
||||
@ENABLE_STATIC_MODULE_FALSE@pkgmodexec_LTLIBRARIES = libhcl-arr.la \
|
||||
@ENABLE_STATIC_MODULE_FALSE@ libhcl-core.la libhcl-dic.la \
|
||||
@ENABLE_STATIC_MODULE_FALSE@ libhcl-str.la libhcl-sys.la
|
||||
libhcl_arr_la_SOURCES = arr.c _arr.h
|
||||
libhcl_arr_la_CPPFLAGS = $(CPPFLAGS_COMMON)
|
||||
libhcl_arr_la_CFLAGS = $(CFLAGS_COMMON)
|
||||
libhcl_arr_la_LDFLAGS = $(LDFLAGS_COMMON)
|
||||
libhcl_arr_la_LIBADD = $(LIBADD_COMMON)
|
||||
@ENABLE_STATIC_MODULE_FALSE@pkgmodexec_LTLIBRARIES = libhcl-core.la \
|
||||
@ENABLE_STATIC_MODULE_FALSE@ libhcl-dic.la libhcl-str.la \
|
||||
@ENABLE_STATIC_MODULE_FALSE@ libhcl-sys.la
|
||||
libhcl_core_la_SOURCES = core.c _core.h
|
||||
libhcl_core_la_CPPFLAGS = $(CPPFLAGS_COMMON)
|
||||
libhcl_core_la_CFLAGS = $(CFLAGS_COMMON)
|
||||
@ -523,9 +506,6 @@ clean-pkgmodexecLTLIBRARIES:
|
||||
rm -f $${locs}; \
|
||||
}
|
||||
|
||||
libhcl-arr.la: $(libhcl_arr_la_OBJECTS) $(libhcl_arr_la_DEPENDENCIES) $(EXTRA_libhcl_arr_la_DEPENDENCIES)
|
||||
$(AM_V_CCLD)$(libhcl_arr_la_LINK) $(am_libhcl_arr_la_rpath) $(libhcl_arr_la_OBJECTS) $(libhcl_arr_la_LIBADD) $(LIBS)
|
||||
|
||||
libhcl-core.la: $(libhcl_core_la_OBJECTS) $(libhcl_core_la_DEPENDENCIES) $(EXTRA_libhcl_core_la_DEPENDENCIES)
|
||||
$(AM_V_CCLD)$(libhcl_core_la_LINK) $(am_libhcl_core_la_rpath) $(libhcl_core_la_OBJECTS) $(libhcl_core_la_LIBADD) $(LIBS)
|
||||
|
||||
@ -544,7 +524,6 @@ mostlyclean-compile:
|
||||
distclean-compile:
|
||||
-rm -f *.tab.c
|
||||
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhcl_arr_la-arr.Plo@am__quote@ # am--include-marker
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhcl_core_la-core.Plo@am__quote@ # am--include-marker
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhcl_dic_la-dic.Plo@am__quote@ # am--include-marker
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhcl_str_la-str.Plo@am__quote@ # am--include-marker
|
||||
@ -580,13 +559,6 @@ am--depfiles: $(am__depfiles_remade)
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
|
||||
|
||||
libhcl_arr_la-arr.lo: arr.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libhcl_arr_la_CPPFLAGS) $(CPPFLAGS) $(libhcl_arr_la_CFLAGS) $(CFLAGS) -MT libhcl_arr_la-arr.lo -MD -MP -MF $(DEPDIR)/libhcl_arr_la-arr.Tpo -c -o libhcl_arr_la-arr.lo `test -f 'arr.c' || echo '$(srcdir)/'`arr.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libhcl_arr_la-arr.Tpo $(DEPDIR)/libhcl_arr_la-arr.Plo
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='arr.c' object='libhcl_arr_la-arr.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) $(libhcl_arr_la_CPPFLAGS) $(CPPFLAGS) $(libhcl_arr_la_CFLAGS) $(CFLAGS) -c -o libhcl_arr_la-arr.lo `test -f 'arr.c' || echo '$(srcdir)/'`arr.c
|
||||
|
||||
libhcl_core_la-core.lo: core.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libhcl_core_la_CPPFLAGS) $(CPPFLAGS) $(libhcl_core_la_CFLAGS) $(CFLAGS) -MT libhcl_core_la-core.lo -MD -MP -MF $(DEPDIR)/libhcl_core_la-core.Tpo -c -o libhcl_core_la-core.lo `test -f 'core.c' || echo '$(srcdir)/'`core.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libhcl_core_la-core.Tpo $(DEPDIR)/libhcl_core_la-core.Plo
|
||||
@ -748,8 +720,7 @@ clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
|
||||
clean-pkgmodexecLTLIBRARIES mostlyclean-am
|
||||
|
||||
distclean: distclean-am
|
||||
-rm -f ./$(DEPDIR)/libhcl_arr_la-arr.Plo
|
||||
-rm -f ./$(DEPDIR)/libhcl_core_la-core.Plo
|
||||
-rm -f ./$(DEPDIR)/libhcl_core_la-core.Plo
|
||||
-rm -f ./$(DEPDIR)/libhcl_dic_la-dic.Plo
|
||||
-rm -f ./$(DEPDIR)/libhcl_str_la-str.Plo
|
||||
-rm -f ./$(DEPDIR)/libhcl_sys_la-sys.Plo
|
||||
@ -798,8 +769,7 @@ install-ps-am:
|
||||
installcheck-am:
|
||||
|
||||
maintainer-clean: maintainer-clean-am
|
||||
-rm -f ./$(DEPDIR)/libhcl_arr_la-arr.Plo
|
||||
-rm -f ./$(DEPDIR)/libhcl_core_la-core.Plo
|
||||
-rm -f ./$(DEPDIR)/libhcl_core_la-core.Plo
|
||||
-rm -f ./$(DEPDIR)/libhcl_dic_la-dic.Plo
|
||||
-rm -f ./$(DEPDIR)/libhcl_str_la-str.Plo
|
||||
-rm -f ./$(DEPDIR)/libhcl_sys_la-sys.Plo
|
||||
|
43
mod/_arr.h
43
mod/_arr.h
@ -1,43 +0,0 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
Copyright (c) 2016-2018 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 _HCL_MOD_ARR_H_
|
||||
#define _HCL_MOD_ARR_H_
|
||||
|
||||
#include <hcl.h>
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
HCL_EXPORT int hcl_mod_arr (hcl_t* hcl, hcl_mod_t* mod);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
224
mod/arr.c
224
mod/arr.c
@ -1,224 +0,0 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
Copyright (c) 2016-2018 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 "_arr.h"
|
||||
|
||||
static hcl_pfrc_t pf_arr_new (hcl_t* hcl, hcl_mod_t* mod, hcl_ooi_t nargs)
|
||||
{
|
||||
hcl_oop_t sz, arr;
|
||||
hcl_oow_t size;
|
||||
|
||||
sz = (hcl_oop_t)HCL_STACK_GETARG(hcl, nargs, 0);
|
||||
if (hcl_inttooow(hcl, sz, &size) == 0) return HCL_PF_FAILURE;
|
||||
|
||||
arr = hcl_makearray(hcl, size, 0);
|
||||
if (HCL_UNLIKELY(!arr)) return HCL_PF_FAILURE;
|
||||
|
||||
HCL_STACK_SETRET (hcl, nargs, arr);
|
||||
return HCL_PF_SUCCESS;
|
||||
}
|
||||
|
||||
static hcl_pfrc_t pf_arr_get (hcl_t* hcl, hcl_mod_t* mod, hcl_ooi_t nargs)
|
||||
{
|
||||
hcl_oop_oop_t arr;
|
||||
hcl_oop_t idx;
|
||||
hcl_oow_t index;
|
||||
|
||||
arr = (hcl_oop_oop_t)HCL_STACK_GETARG(hcl, nargs, 0);
|
||||
idx = HCL_STACK_GETARG(hcl, nargs, 1);
|
||||
|
||||
if (!HCL_IS_ARRAY(hcl,arr))
|
||||
{
|
||||
hcl_seterrbfmt (hcl, HCL_EINVAL, "parameter not an array - %O", arr);
|
||||
return HCL_PF_FAILURE;
|
||||
}
|
||||
|
||||
if (hcl_inttooow(hcl, idx, &index) == 0) return HCL_PF_FAILURE;
|
||||
|
||||
if (index >= HCL_OBJ_GET_SIZE(arr))
|
||||
{
|
||||
hcl_seterrbfmt (hcl, HCL_EINVAL, "array index %zu out of bounds for array of size %zu", index, HCL_OBJ_GET_SIZE(arr));
|
||||
return HCL_PF_FAILURE;
|
||||
}
|
||||
|
||||
HCL_STACK_SETRET (hcl, nargs, arr->slot[index]);
|
||||
return HCL_PF_SUCCESS;
|
||||
}
|
||||
|
||||
static hcl_pfrc_t pf_arr_put (hcl_t* hcl, hcl_mod_t* mod, hcl_ooi_t nargs)
|
||||
{
|
||||
hcl_oop_oop_t arr;
|
||||
hcl_oop_t idx, val;
|
||||
hcl_oow_t index;
|
||||
|
||||
arr = (hcl_oop_oop_t)HCL_STACK_GETARG(hcl, nargs, 0);
|
||||
idx = HCL_STACK_GETARG(hcl, nargs, 1);
|
||||
val = HCL_STACK_GETARG(hcl, nargs, 2);
|
||||
|
||||
if (!HCL_IS_ARRAY(hcl,arr))
|
||||
{
|
||||
hcl_seterrbfmt (hcl, HCL_EINVAL, "parameter not an array - %O", arr);
|
||||
return HCL_PF_FAILURE;
|
||||
}
|
||||
|
||||
if (hcl_inttooow(hcl, idx, &index) == 0) return HCL_PF_FAILURE;
|
||||
|
||||
if (index >= HCL_OBJ_GET_SIZE(arr))
|
||||
{
|
||||
hcl_seterrbfmt (hcl, HCL_EINVAL, "array index %zu out of bounds for array of size %zu", index, HCL_OBJ_GET_SIZE(arr));
|
||||
return HCL_PF_FAILURE;
|
||||
}
|
||||
|
||||
arr->slot[index] = val;
|
||||
HCL_STACK_SETRET (hcl, nargs, val);
|
||||
return HCL_PF_SUCCESS;
|
||||
}
|
||||
|
||||
static hcl_pfrc_t pf_arr_size (hcl_t* hcl, hcl_mod_t* mod, hcl_ooi_t nargs)
|
||||
{
|
||||
hcl_oop_oop_t src;
|
||||
hcl_oop_t size;
|
||||
|
||||
src = (hcl_oop_oop_t)HCL_STACK_GETARG(hcl, nargs, 0);
|
||||
|
||||
if (!HCL_OOP_IS_POINTER(src))
|
||||
{
|
||||
hcl_seterrbfmt (hcl, HCL_EINVAL, "source not sizable - %O", src);
|
||||
return HCL_PF_FAILURE;
|
||||
}
|
||||
|
||||
size = hcl_oowtoint(hcl, HCL_OBJ_GET_SIZE(src));
|
||||
if (!size) return HCL_PF_FAILURE;
|
||||
|
||||
HCL_STACK_SETRET (hcl, nargs, size);
|
||||
return HCL_PF_SUCCESS;
|
||||
}
|
||||
|
||||
static hcl_pfrc_t pf_arr_slice (hcl_t* hcl, hcl_mod_t* mod, hcl_ooi_t nargs)
|
||||
{
|
||||
hcl_oop_t src, slice, a1, a2;
|
||||
hcl_ooi_t size;
|
||||
hcl_ooi_t pos;
|
||||
hcl_ooi_t len;
|
||||
hcl_ooi_t i;
|
||||
|
||||
src = HCL_STACK_GETARG(hcl, nargs, 0);
|
||||
a1 = HCL_STACK_GETARG(hcl, nargs, 1);
|
||||
a2 = HCL_STACK_GETARG(hcl, nargs, 2);
|
||||
|
||||
if (!HCL_OOP_IS_POINTER(src))
|
||||
{
|
||||
unsliceable:
|
||||
hcl_seterrbfmt (hcl, HCL_EINVAL, "source not sliceable - %O", src);
|
||||
return HCL_PF_FAILURE;
|
||||
}
|
||||
|
||||
if (!HCL_OOP_IS_SMOOI(a1))
|
||||
{
|
||||
hcl_seterrbfmt (hcl, HCL_EINVAL, "position not numeric - %O", a1);
|
||||
return HCL_PF_FAILURE;
|
||||
}
|
||||
if (!HCL_OOP_IS_SMOOI(a2))
|
||||
{
|
||||
hcl_seterrbfmt (hcl, HCL_EINVAL, "length not numeric - %O", a2);
|
||||
return HCL_PF_FAILURE;
|
||||
}
|
||||
|
||||
size = HCL_OBJ_GET_SIZE(src);
|
||||
pos = HCL_OOP_TO_SMOOI(a1);
|
||||
len = HCL_OOP_TO_SMOOI(a2);
|
||||
|
||||
if (pos < 0) pos = 0;
|
||||
else if (pos >= size) pos = size;
|
||||
if (len >= size - pos) len = size - pos;
|
||||
|
||||
/* TODO: check if the object is an indexable object from the class spec... */
|
||||
/* use HCL_OBJ_GET_CLASS() instead of HCL_CLASSOF() as we know it's an object */
|
||||
slice = hcl_instantiate(hcl, (hcl_oop_class_t)HCL_OBJ_GET_CLASS(src), HCL_NULL, len);
|
||||
if (HCL_UNLIKELY(!slice)) return HCL_PF_FAILURE;
|
||||
|
||||
/* OR if add by the number of fixed fields??? */
|
||||
switch (HCL_OBJ_GET_FLAGS_TYPE(src))
|
||||
{
|
||||
case HCL_OBJ_TYPE_OOP:
|
||||
for (i = 0; i < len; i++) HCL_OBJ_GET_OOP_VAL(slice, i) = HCL_OBJ_GET_OOP_VAL(src, pos + i);
|
||||
break;
|
||||
|
||||
case HCL_OBJ_TYPE_CHAR:
|
||||
for (i = 0; i < len; i++) HCL_OBJ_GET_CHAR_VAL(slice, i) = HCL_OBJ_GET_CHAR_VAL(src, pos + i);
|
||||
break;
|
||||
|
||||
case HCL_OBJ_TYPE_BYTE:
|
||||
for (i = 0; i < len; i++) HCL_OBJ_GET_BYTE_VAL(slice, i) = HCL_OBJ_GET_BYTE_VAL(src, pos + i);
|
||||
break;
|
||||
|
||||
case HCL_OBJ_TYPE_HALFWORD:
|
||||
for (i = 0; i < len; i++) HCL_OBJ_GET_HALFWORD_VAL(slice, i) = HCL_OBJ_GET_HALFWORD_VAL(src, pos + i);
|
||||
break;
|
||||
|
||||
case HCL_OBJ_TYPE_WORD:
|
||||
for (i = 0; i < len; i++) HCL_OBJ_GET_WORD_VAL(slice, i) = HCL_OBJ_GET_WORD_VAL(src, pos + i);
|
||||
break;
|
||||
|
||||
default:
|
||||
goto unsliceable;
|
||||
break;
|
||||
}
|
||||
|
||||
HCL_STACK_SETRET (hcl, nargs, slice);
|
||||
return HCL_PF_SUCCESS;
|
||||
}
|
||||
|
||||
static hcl_pfinfo_t pfinfos[] =
|
||||
{
|
||||
{ { 'g','e','t','\0' }, { HCL_PFBASE_FUNC, pf_arr_get, 2, 2 } },
|
||||
{ { 'l','e','n','g','t','h','\0' }, { HCL_PFBASE_FUNC, pf_arr_size, 1, 1 } },
|
||||
{ { 'n','e','w','\0' }, { HCL_PFBASE_FUNC, pf_arr_new, 1, 1 } },
|
||||
{ { 'p','u','t','\0' }, { HCL_PFBASE_FUNC, pf_arr_put, 3, 3 } },
|
||||
{ { 's','i','z','e','\0' }, { HCL_PFBASE_FUNC, pf_arr_size, 1, 1 } },
|
||||
{ { 's','l','i','c','e','\0' }, { HCL_PFBASE_FUNC, pf_arr_slice, 3, 3 } }
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
static hcl_pfbase_t* query (hcl_t* hcl, hcl_mod_t* mod, const hcl_ooch_t* name, hcl_oow_t namelen)
|
||||
{
|
||||
return hcl_findpfbase(hcl, pfinfos, HCL_COUNTOF(pfinfos), name, namelen);
|
||||
}
|
||||
|
||||
|
||||
static void unload (hcl_t* hcl, hcl_mod_t* mod)
|
||||
{
|
||||
}
|
||||
|
||||
int hcl_mod_arr (hcl_t* hcl, hcl_mod_t* mod)
|
||||
{
|
||||
mod->query = query;
|
||||
mod->unload = unload;
|
||||
mod->ctx = HCL_NULL;
|
||||
return 0;
|
||||
}
|
26
mod/core.c
26
mod/core.c
@ -48,6 +48,23 @@ static hcl_pfrc_t pf_core_get_class_name (hcl_t* hcl, hcl_mod_t* mod, hcl_ooi_t
|
||||
return HCL_PF_SUCCESS;
|
||||
}
|
||||
|
||||
#if 0
|
||||
static hcl_pfrc_t pf_arr_new (hcl_t* hcl, hcl_mod_t* mod, hcl_ooi_t nargs)
|
||||
{
|
||||
hcl_oop_t sz, arr;
|
||||
hcl_oow_t size;
|
||||
|
||||
sz = (hcl_oop_t)HCL_STACK_GETARG(hcl, nargs, 0);
|
||||
if (hcl_inttooow(hcl, sz, &size) == 0) return HCL_PF_FAILURE;
|
||||
|
||||
arr = hcl_makearray(hcl, size, 0);
|
||||
if (HCL_UNLIKELY(!arr)) return HCL_PF_FAILURE;
|
||||
|
||||
HCL_STACK_SETRET (hcl, nargs, arr);
|
||||
return HCL_PF_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
|
||||
static hcl_pfrc_t pf_core_size (hcl_t* hcl, hcl_mod_t* mod, hcl_ooi_t nargs)
|
||||
{
|
||||
hcl_oop_oop_t src;
|
||||
@ -147,7 +164,7 @@ static hcl_pfrc_t pf_core_get (hcl_t* hcl, hcl_mod_t* mod, hcl_ooi_t nargs)
|
||||
{
|
||||
hcl_oop_t obj, val;
|
||||
hcl_oop_t pos;
|
||||
hcl_oow_t index;
|
||||
hcl_ooi_t index;
|
||||
|
||||
obj = HCL_STACK_GETARG(hcl, nargs, 0);
|
||||
pos = HCL_STACK_GETARG(hcl, nargs, 1);
|
||||
@ -167,7 +184,7 @@ static hcl_pfrc_t pf_core_get (hcl_t* hcl, hcl_mod_t* mod, hcl_ooi_t nargs)
|
||||
index = HCL_OOP_TO_SMOOI(pos);
|
||||
if (index < 0 || index >= HCL_OBJ_GET_SIZE(obj))
|
||||
{
|
||||
hcl_seterrbfmt (hcl, HCL_EINVAL, "position(%O) out of range - 0 and %zu", pos, (hcl_oow_t)HCL_OBJ_GET_SIZE(obj) - 1);
|
||||
hcl_seterrbfmt (hcl, HCL_EINVAL, "position(%zd) out of range - negative or greater than or equal to %zu", index, (hcl_ooi_t)HCL_OBJ_GET_SIZE(obj));
|
||||
return HCL_PF_FAILURE;
|
||||
}
|
||||
|
||||
@ -216,7 +233,7 @@ static hcl_pfrc_t pf_core_put (hcl_t* hcl, hcl_mod_t* mod, hcl_ooi_t nargs)
|
||||
{
|
||||
hcl_oop_t obj, val;
|
||||
hcl_oop_t pos;
|
||||
hcl_oow_t index;
|
||||
hcl_ooi_t index;
|
||||
|
||||
obj = HCL_STACK_GETARG(hcl, nargs, 0);
|
||||
pos = HCL_STACK_GETARG(hcl, nargs, 1);
|
||||
@ -237,7 +254,7 @@ static hcl_pfrc_t pf_core_put (hcl_t* hcl, hcl_mod_t* mod, hcl_ooi_t nargs)
|
||||
index = HCL_OOP_TO_SMOOI(pos);
|
||||
if (index < 0 || index >= HCL_OBJ_GET_SIZE(obj))
|
||||
{
|
||||
hcl_seterrbfmt (hcl, HCL_EINVAL, "position(%O) out of range - 0 and %zu", pos, (hcl_oow_t)HCL_OBJ_GET_SIZE(obj) - 1);
|
||||
hcl_seterrbfmt (hcl, HCL_EINVAL, "position(%zd) out of range - negative or greater than or equal to %zu", index, (hcl_ooi_t)HCL_OBJ_GET_SIZE(obj));
|
||||
return HCL_PF_FAILURE;
|
||||
}
|
||||
|
||||
@ -318,7 +335,6 @@ static hcl_pfbase_t* query (hcl_t* hcl, hcl_mod_t* mod, const hcl_ooch_t* name,
|
||||
return hcl_findpfbase(hcl, pfinfos, HCL_COUNTOF(pfinfos), name, namelen);
|
||||
}
|
||||
|
||||
|
||||
static void unload (hcl_t* hcl, hcl_mod_t* mod)
|
||||
{
|
||||
}
|
||||
|
@ -110,8 +110,9 @@ fun X:xxx() { ##ERROR: exception not handled - "not class"
|
||||
## you can't place an item in the arrya at all.
|
||||
|
||||
fun Array:*boom() {
|
||||
arr.put self 0 10 ##ERROR: exception not handled - "array index 0 out of bounds for array of size 0"
|
||||
core.put self 0 10 ##ERROR: exception not handled - "position(0) out of range - negative or greater than or equal to 0"
|
||||
printf "%O" self
|
||||
return self
|
||||
}
|
||||
Array:boom
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user