/****************************************************************************
 * KONOHA COPYRIGHT, LICENSE NOTICE, AND DISCRIMER  
 * 
 * Copyright (c) 2005-2008, Kimio Kuramitsu <kimio at ynu.ac.jp>
 *           (c) 2008-      Konoha Software Foundation  
 * All rights reserved.
 * 
 * You may choose one of the following two licenses when you use konoha. 
 * See www.konohaware.org/license.html for further information.
 * 
 * (1) GNU General Public License 2.0      (with    KONOHA_UNDER_GPL2)
 * (2) Konoha Software Foundation License 1.0
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "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 COPYRIGHT OWNER 
 * OR CONTRIBUTORS 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 KONOHA_KNHAPI__H
#define KONOHA_KNHAPI__H

#include<konoha/gen/konoha_class_.h>


#ifdef __cplusplus 
extern "C" {
#endif

/* ======================================================================== */

/* ======================================================================== */
/* [MACROS] */
#define knh_AffineConv_struct_copy      NULL
#define knh_AffineConv_struct_compare   NULL
#define knh_AffineConv_struct_traverse  NULL
#define KNH_FLAG_MMF_AFFINE (KNH_FLAG_MMF_SIGNIFICANT|KNH_FLAG_MMF_SYNONYM|KNH_FLAG_MMF_TOTAL|KNH_FLAG_MMF_STATIC)
#define knh_Array_n(a,n)      (a)->list[(n)]
#define knh_Array_size(a)     (a)->size
#define IS_TRUE(o)             (o != KNH_FALSE && IS_NOTNULL(o))
#define IS_FALSE(o)            (o == KNH_FALSE || IS_NULL(o))
#define BOOL_ISTRUE(o)         (o == KNH_TRUE)
#define BOOL_ISFALSE(o)        (o == KNH_FALSE)
#define new_Boolean(ctx,b)     ((b) ? KNH_TRUE : KNH_FALSE)
#define knh_Bytes_size(o)      (o)->size
#define knh_Bytes_value(o)     (o)->buf
#define knh_Bytes_last(o)      ((o)->buf + (o)->size)
#define knh_Bytes_tochar(b)  (char*)knh_Bytes_value(b)
#define knh_BytesConv_struct_copy NULL
#define knh_BytesConv_struct_compare NULL
#define KNH_SIZE(v)         knh_size(v)
#define B(c)     new_bytes(c)
#define B2(c,n)   new_bytes__2(c,n)
#define STEXT(c)  new_bytes__2(c,sizeof(c)-1)
#define ISB(t,c) (t.len == (sizeof(c)-1) && knh_strncmp((char*)t.buf,c,t.len) == 0)
#define CLASS_newid          ((knh_class_t)-1)
#define CLASS_unknown        ((knh_class_t)-2)
#define knh_Class_cid(c)     (knh_class_t)(c)->cid
#define knh_ClassMap_struct_copy    NULL
#define knh_ClassMap_struct_compare  NULL
#define knh_tstruct_isNative(sid)   (sid < KONOHA_TSTRUCT_SIZE)
#define knh_ClassStruct_struct_copy    NULL
#define knh_Class_getMethod(ctx, c, mn)    knh_Class_getMethod__(ctx, c, mn, 0)
#define knh_Class_findMethod(ctx, c, mn)   knh_Class_getMethod__(ctx, c, mn, 1)
#define IS_SPEC(o)   (CLASS_IntUnit <= knh_Object_cid(o)  && knh_Object_cid(o) <= CLASS_Vocabulary)
#define KNH_FLAG_TF_NN                KNH_FLAG_T0
#define TYPE_ISNULLABLE(t)            ((t & KNH_FLAG_TF_NN)==0)   
#define TYPE_ISNOTNULL(t)             ((t & KNH_FLAG_TF_NN)==KNH_FLAG_TF_NN)
#define CLASS_TONNTYPE(c)             (c|KNH_FLAG_TF_NN)
#define TYPE_TONNTYPE(t)              (t|KNH_FLAG_TF_NN)
#define TYPE_UNMASK(t)                (t&(~(KNH_FLAG_TF_NN|KNH_FLAG_T1)))
#define TYPE_UNMASK_NN(t)             (t&(~KNH_FLAG_TF_NN))
#define TYPEQN(t)                     TYPEN(t), TYPEQ(t)
#define TYPE_void                     CLASS_TONNTYPE(CLASS_Nue)
#define NNTYPE_void                   CLASS_TONNTYPE(CLASS_Nue)
#define TYPE_any                      CLASS_Any
#define NNTYPE_any                    CLASS_any
#define TYPEN(type)  knh_TYPEN(ctx,type)
#define knh_Connection_struct_copy    NULL
#define knh_Connection_struct_compare  NULL
#define KNH_STDIN          (((Context*)ctx)->in)
#define KNH_STDOUT         (((Context*)ctx)->out)
#define KNH_STDERR         (((Context*)ctx)->err)
#define knh_DictIdx_struct_copy   NULL
#define knh_DictMap_put(ctx,b,k,v) knh_DictMap_set(ctx,b,k,v)
#define knh_DictMap_put(ctx,b,k,v) knh_DictMap_set(ctx,b,k,v)
#define knh_DictMap_String__   knh_DictMap_Iterator
#define knh_DictSet_put(ctx,b,k,v) knh_DictSet_set(ctx,b,k,v)
#define EXPT_newid            ((knh_expt_t)0)
#define EXPT_Exception        ((knh_expt_t)1)
#define EXPT_NoSuchException  ((knh_expt_t)2)
#define knh_Exception_eid(o)   (o)->eid
#define knh_Exception_struct_copy   NULL
#define knh_Exception_struct_compare  NULL
#define new_Exception__s(ctx, s)     new_Exception__b(ctx, B(s))
#define KNH_SETJUMP(hdlr)   setjmp(DP((ExceptionHandler*)hdlr)->jmpbuf)
#define knh_ExceptionHandler_struct_copy   NULL
#define knh_ExceptionHandler_struct_compare  NULL
#define knh_Float_value(o)    (o)->value
#define knh_FloatUnit_struct_copy    NULL
#define knh_FloatUnit_struct_compare NULL
#define LRUMap                          HashMap
#define knh_LRUMap                      knh_HashMap_struct
#define new_LRUMap(ctx,n)               new_HashMap(ctx,n)
#define knh_LRUMap_get(ctx,b,kh,ko)     knh_HashMap_get(ctx,b,kh,ko)
#define knh_LRUMap_set(ctx,b,kh,ko,v)   knh_HashMap_set(ctx,b,kh,ko,v)
#define knh_HashMap_struct_copy NULL
#define knh_HashMap_struct_compare NULL
#define knh_HashSet_struct_copy NULL
#define knh_HashSet_struct_compare NULL
#define knh_InputStream_struct_copy   NULL
#define knh_InputStream_struct_compare  NULL
#define knh_Int_value(o)      (o)->value
#define knh_IntUnit_isBuffered(u,n)   (DP(u)->bfarray != NULL && DP(u)->bfoffset <= n && n < DP(u)->bfoffset + DP(u)->bfsize)
#define knh_IntUnit_struct_copy    NULL
#define knh_IntUnit_struct_compare NULL
#define KNH_SMARTcid(o, alt)   (IS_Class(o)) ? (o)->cid : (alt)
#define knh_Iterator_cid(it)           DP(it)->cid
#define knh_Iterator_source(it)        DP(it)->source
#define knh_Iterator_pos(it)           DP(it)->pos
#define knh_Iterator_setpos(it, p)     DP(it)->pos = p
#define knh_Iterator_ref(it)           DP(it)->ref
#define knh_LRUHashMap_struct_copy NULL
#define knh_HashMap_struct_compare NULL
#define knh_Mapper_struct_copy NULL
#define knh_Method_mn(mtd)    DP(mtd)->mn
#define knh_Method_mf(mtd)    DP(mtd)->mf
#define knh_Method_rtype(mtd)          knh_MethodField_rtype(knh_Method_mf(mtd))
#define knh_Method_psize(mtd)      knh_MethodField_psize(knh_Method_mf(mtd))
#define knh_Method_ptype(mtd,n)          knh_MethodField_ptype(knh_Method_mf(mtd),n)
#define knh_Method_pfields(mtd,n)   knh_MethodField_pfields(knh_Method_mf(mtd),n)
#define knh_Method_lastfield(mtd)   knh_MethodField_lastfield(knh_Method_mf(mtd))
#define knh_NameSpace_struct_copy  NULL
#define knh_NameSpace_struct_compare NULL
#define CTXCLASSN(cid)     knh_Context_CLASSN(ctx,cid)
#define CTXTYPEQN(cid)     knh_Context_CLASSN(ctx,TYPE_UNMASK_NN(cid)), TYPEQ(cid)
#define IS_NULL(o)          (((Object*)o)->h.cid == CLASS_Nue)
#define IS_NOTNULL(o)       (((Object*)o)->h.cid != CLASS_Nue)
#define new_Nue__b(ctx, txt)   new_Nue(ctx, new_String(ctx, txt, NULL));
#define new_Nue__s(ctx, txt)   new_Nue(ctx, new_String(ctx, B(txt), NULL));
#define knh_Object_cid(o)           (o)->h.cid
#define knh_Object_bcid(o)          (o)->h.bcid
#define knh_OutputStream_struct_copy      NULL
#define knh_OutputStream_struct_compare   NULL
#define knh_write_delim(ctx, w)    knh_write(ctx, w, STEXT(", "))
#define knh_write_dots(ctx, w)     knh_write(ctx, w, STEXT("..."))
#define knh_write__i(ctx, w, n)   knh_write__ifmt(ctx, w, KNH_INT_FMT, n)
#define knh_write__u(ctx, w, n)   knh_write__ifmt(ctx, w, KNH_UINT_FMT, n)
#define knh_write__x(ctx, w, n)   knh_write__ifmt(ctx, w, KNH_INT_FMTX, n)
#define knh_write__f(ctx, w, f)  knh_write__ffmt(ctx, w, KNH_FLOAT_FMT, f)
#define knh_write__e(ctx, w, f)  knh_write__ffmt(ctx, w, KNH_FLOAT_FMTE, f)
#define knh_write__fn(ctx, w, fn)   knh_write__s(ctx, w, FIELDN(fn))
#define knh_write__O(ctx, w, o)    knh_format(ctx, w, METHODN__k, o, KNH_NULL)
#define knh_Object_toString(ctx, b)   knh_Object_movableText(ctx, b, METHODN__s, KNH_NULL)
#define knh_ResultSet_struct_copy NULL
#define knh_ResultSet_struct_compare NULL
#define knh_Runtime_struct_copy  NULL
#define knh_Runtime_struct_compare NULL
#define knh_String_value(o)   ((o)->str)
#define knh_String_tochar(o)  (char*)((o)->str)
#define knh_String_strlen(o)  (o)->size
#define knh_bytes_hcode(t)     knh_string_hash((t).buf, (t).len)
#define knh_StringUnit_struct_copy   NULL
#define knh_StringUnit_struct_compare  NULL
#define NSN_main           0
#define FILEN_unknown      0
#define knh_Compiler_struct_copy   NULL
#define knh_Compiler_struct_compare  NULL
#define knh_KLRCode_struct_compare  NULL
#define KNH_PERRATA_(ctx, f, l, msgo, msgn)    knh_perrata(ctx, f, l, msgo, msgn)
#define KNH_PERRATA(ctx, tk, msg)  knh_perrata(ctx, (tk)->fileid, (tk)->line, knh_Token_tochar(tk), msg)
#define knh_Stmt_struct_copy  NULL
#define knh_Stmt_struct_compare  NULL
#define knh_Stmt_terms_cmpl(ctx, stmt, n, cpr, ns, reqt, level)      knh_Stmt_terms_cmpl_(ctx, stmt, n, cpr, ns, reqt, level, 0)
#define knh_Stmt_terms_cmplpush(ctx, stmt, n, cpr, ns, reqt, level)  knh_Stmt_terms_cmpl_(ctx, stmt, n, cpr, ns, reqt, level, 1)
#define knh_Token_struct_copy  NULL
#define knh_Token_struct_compare  NULL
#define KNH_FLAG_CF2OF(f)        (f)
#define knh_tClass_isPMZ(cid)    (knh_tClass[cid].p1 != CLASS_Nue)
#define DEBUG_ASSERT_cid(cid)    KNH_ASSERT(IS_cid(cid))
#define CLASSN(cid)   knh_String_tochar(knh_tClass[cid].lname)
#define CLASSNo(o)    knh_String_tochar(knh_tClass[(o)->h.cid].lname)
#define KNH_TMAPMAP  KNH_TMAPPER
#define FIELDN_NONAME    ((knh_fieldn_t)-1)
#define FIELDN_NEWID     ((knh_fieldn_t)-2)
#define FIELDN_return    FIELDN_
#define METHODN_NONAME   ((knh_methodn_t)-1)
#define METHODN_NEWID    ((knh_methodn_t)-2)
#define KNH_FLAG_FN_SUPER   KNH_FLAG_T0
#define KNH_FLAG_FN_U1      KNH_FLAG_T1
#define KNH_FLAG_FN_U2      KNH_FLAG_T2
#define FIELDN_IS_SUPER(fnq)       ((fnq & KNH_FLAG_FN_SUPER) == KNH_FLAG_FN_SUPER)
#define FIELDN_IS_U1(fnq)          ((fnq & KNH_FLAG_FN_U1) == KNH_FLAG_FN_U1)
#define FIELDN_IS_U2(fnq)          ((fnq & KNH_FLAG_FN_U2) == KNH_FLAG_FN_U2)
#define FIELDN_IS_PROTECTED(fnq)   (FIELDN_IS_U1(fnq)||FIELDN_IS_U2(fnq))
#define FIELDN_UNMASK(fnq)         (fnq & (~(KNH_FLAG_FN_SUPER|KNH_FLAG_FN_U1|KNH_FLAG_FN_U2)))
#define KNH_FLAG_MN_SUPER        KNH_FLAG_T0
#define KNH_FLAG_MN_GETTER       KNH_FLAG_T1
#define KNH_FLAG_MN_SETTER       KNH_FLAG_T2
#define KNH_FLAG_MN_MOVTEXT      (KNH_FLAG_T1|KNH_FLAG_T2)
#define KNH_FLAG_MN_FIELDN       (~(KNH_FLAG_T0|KNH_FLAG_T1|KNH_FLAG_T2))
#define METHODN_IS_GETTER(mn)   ((mn & KNH_FLAG_MN_MOVTEXT) == KNH_FLAG_MN_GETTER)
#define METHODN_TO_GETTER(mn)   (mn | KNH_FLAG_MN_GETTER)
#define METHODN_IS_SETTER(mn)   ((mn & KNH_FLAG_MN_MOVTEXT) == KNH_FLAG_MN_SETTER)
#define METHODN_TO_SETTER(mn)   (mn | KNH_FLAG_MN_SETTER)
#define METHODN_IS_MOVTEXT(mn)  ((mn & KNH_FLAG_MN_MOVTEXT) == KNH_FLAG_MN_MOVTEXT)
#define METHODN_TO_MOVTEXT(mn)  (mn | KNH_FLAG_MN_MOVTEXT)
#define METHODN_TOFIELDN(mn)     (mn & KNH_FLAG_MN_FIELDN)
#define FIELDN(fn) knh_String_tochar(knh_tfieldn_name(fn))
#define FILEIDN(fileid) knh_String_tochar(knh_tfileid_name(fileid))
#define new_Object_malloc(ctx, flag, cid, size)   new_ObjectX_malloc(ctx, flag, cid, cid, size)
#define IS_SWEEP(f)   (f == knh_Object_RCsweep)
#define knh_rootNameSpace    DP(knh_rootSystem)->ns
#define knh_systemEncoding    DP(knh_rootSystem)->enc
#define knh_systemStdIn       DP(knh_rootSystem)->in
#define knh_systemStdOut      DP(knh_rootSystem)->out
#define knh_systemStdErr      DP(knh_rootSystem)->err
#define knh_tMethodField_add(ctx, mf)       knh_Array_add(ctx, DP(knh_rootSystem)->tMethodFields, UP(mf))
#define knh_tMethodField(n)                 (MethodField*)knh_Array_n(DP(knh_rootSystem)->tMethodFields, n)
#define knh_tMethodField_size               knh_Array_size(DP(knh_rootSystem)->tMethodFields)
#define new_Int(ctx, n)      new_Int__fast(ctx, CLASS_Int, (n))
#define new_Int64(ctx, n)      new_Int64__fast(ctx, CLASS_Int64, (n))
#define new_Float(ctx, n)      new_Float__fast(ctx, CLASS_Float, (n))
#define new_String__T(ctx, text)    new_StringX__T(ctx, CLASS_String, text)
#define KNH_FLAG_SF_FIELD          KNH_FLAG_T1
#define STRUCT_ISFIELD(sid)        ((sid & KNH_FLAG_SF_FIELD) == KNH_FLAG_SF_FIELD)
#define BSIZE_TOSID(bsize)         (((knh_struct_t)bsize)|KNH_FLAG_SF_FIELD)
#define STRUCT_FIELD(bsize)        (((knh_struct_t)bsize)|KNH_FLAG_SF_FIELD)
#define STRUCT_FIELDSIZE(sid)      (sid & (~KNH_FLAG_SF_FIELD))
#define STRUCT_UNMASK(sid)         (sid & (~KNH_FLAG_SF_FIELD))
#define DEBUG_ASSERT_sid(sid)   KNH_ASSERT(IS_sid(sid))
#define STRUCTN(sid)   knh_tstruct_name(sid)
#define KNH_LOPEN(ctx, n) \
	knh_sfp_t *lbp_ = ((Context*)ctx)->ebp + 1; \
	knh_stackf_locals(ctx, n) \


#define KNH_LOCALn(n)                 (lbp_[n].o)
#define KNH_LSETv(ctx, n, v)          KNH_SETv(ctx, lbp_[n].o, v) 
#define KNH_LCLOSE(ctx)               ((Context*)ctx)->ebp = lbp_ - 1 
#define KNH_LPUSH(ctx,v) \
	((Context*)ctx)->ebp++; \
	KNH_SETv(ctx, ((Context*)ctx)->ebp[0].o, v); \


#define KNH_PUSHv(ctx,v) \
	((Context*)ctx)->ebp++; \
	KNH_SETv(ctx, ((Context*)ctx)->ebp[0].o, v); \
*/

#define KNH_FLAG_PF_STDERR      KNH_FLAG_T0
#define KNH_FLAG_PF_EOL         KNH_FLAG_T1
#define KNH_FLAG_PF_TIME        KNH_FLAG_T2
#define KNH_FLAG_PF_FUNC        KNH_FLAG_T3
#define KNH_FLAG_PF_NAME        KNH_FLAG_T4
#define KNH_FLAG_PF_NOCOMMA     KNH_FLAG_T5
#define KNH_FLAG_PF_EMPTY       KNH_FLAG_T6
#define KNH_FLAG_PF_BOL         KNH_FLAG_T7
#define KNH_THROW(ctx, e) \
	if(IS_NULL(e)) { \
		knh_konohavm_throwException(ctx, new_Exception__Nue(ctx, (Nue*)e)); \
	}else if(IS_Exception(e)) { \
		knh_konohavm_throwException(ctx, (Exception*)e); \
	}else if(IS_bString(e)) { \
		knh_konohavm_throwException(ctx, new_Exception(ctx, (String*)e)); \
	}else { \
		DBG2_P("Cannot throw %s", CLASSN(knh_Object_cid(e))); \
	} \


#define KNH_THROWs(ctx, s) \
	knh_konohavm_throwException(ctx, new_Exception__b(ctx, B(s))); \


#define KNH_THROWf(ctx, fmt, ...) \
	char throwbuf_[256]; \
	knh_snprintf(throwbuf_, sizeof(throwbuf_), fmt, ## __VA_ARGS__); \
	knh_konohavm_throwException(ctx, new_Exception__b(ctx, B(throwbuf_))); \


#define TODO_THROW(ctx) \
	char throwbuf_[256]; \
	knh_snprintf(throwbuf_, sizeof(throwbuf_), "Nakata!!: please call him to check %s", __FUNCTION__); \
	knh_konohavm_throwException(ctx, new_Exception__b(ctx, B(throwbuf_))); \
	


/* ======================================================================== */
/* [PROTOTYPE] */
void KNHAPI konoha_addDataBaseDriver(Ctx *ctx, char *alias, knh_db_drvapi_t *d);
void KNHAPI konoha_addInputStreamDriver(Ctx *ctx, char *alias, knh_inptr_drvapi_t *d);
void KNHAPI knh_putc(Ctx *ctx, OutputStream *w, int ch);
void KNHAPI knh_write(Ctx *ctx, OutputStream *w, knh_bytes_t s);
void KNHAPI knh_flush(Ctx *ctx, OutputStream *w);
void KNHAPI knh_print(Ctx *ctx, OutputStream *w, knh_bytes_t s);
void KNHAPI knh_println(Ctx *ctx, OutputStream *w, knh_bytes_t s);
void KNHAPI knh_write_EOL(Ctx *ctx, OutputStream *w);
void KNHAPI knh_write_tab(Ctx *ctx, OutputStream *w);
void KNHAPI knh_write_BOL(Ctx *ctx, OutputStream *w);
void KNHAPI knh_printf(Ctx *ctx, OutputStream *w, char *fmt, ...);
void KNHAPI konoha_addRegexDriver(Ctx *ctx, char *alias, knh_regex_drvapi_t *d);
ResultSet* KNHAPI new_ResultSet(Ctx *ctx, Connection *conn, size_t column_size, knh_rshdlr_t *rsptr);
void KNHAPI knh_ResultSet_initMetaInfo(Ctx *ctx, ResultSet *o, size_t n, knh_type_t type, String *name);
void KNHAPI knh_ResultSet_initData(Ctx *ctx, ResultSet *o);
void KNHAPI knh_ResultSet_set__int(Ctx *ctx, ResultSet *o, size_t n, knh_int_t value);
void KNHAPI knh_ResultSet_set__float(Ctx *ctx, ResultSet *o, size_t n, knh_float_t value);
void KNHAPI knh_ResultSet_set__int64(Ctx *ctx, ResultSet *o, size_t n, knh_int64_t value);
void KNHAPI knh_ResultSet_set__bytes(Ctx *ctx, ResultSet *o, size_t n, knh_bytes_t t);
void KNHAPI knh_ResultSet_set__null(Ctx *ctx, ResultSet *o, size_t n);
konoha_t KNHAPI konoha_open(void);
void KNHAPI konoha_close(konoha_t konoha);
Ctx* KNHAPI konoha_open_context(konoha_t konoha);
void KNHAPI konoha_close_context(konoha_t konoha, Ctx *ctx);
void KNHAPI konoha_read(Ctx *ctx, char *fpath);
int KNHAPI konoha_main(Ctx *ctx, int argc, char **argv);
knh_class_t KNHAPI konoha_addVirtualClass(Ctx *ctx, char *name, int method_size);
void KNHAPI konoha_addMethod(Ctx *ctx, char *kscript, f_method f);
void KNHAPI konoha_addIntConst(Ctx *ctx, char *name, knh_int_t value);
void KNHAPI konoha_addInt64Const(Ctx *ctx, char *name, knh_int64_t value);
void KNHAPI konoha_addFloatConst(Ctx *ctx, char *name, knh_float_t value);
void KNHAPI konoha_addStringConst(Ctx *ctx, char *name, char *text);
void KNHAPI konoha_addDriver(Ctx *ctx, char *name, int type, void *drv);
void KNHAPI konoha_shell(Ctx *ctx);
size_t KNHAPI knh_stat_usedMemorySize(void);
f_traverse KNHAPI konoha_sweep();
int KNHAPI konoha_issweep(f_traverse ftr);
Int* KNHAPI new_Int__fast(Ctx *ctx, knh_class_t cid, knh_int_t value);
Int64* KNHAPI new_Int64__fast(Ctx *ctx, knh_class_t cid, knh_int64_t value);
Float* KNHAPI new_Float__fast(Ctx *ctx, knh_class_t cid, knh_float_t value);
void KNHAPI konoha_addParserDriver(Ctx *ctx, char *alias, knh_parser_drvapi_t *d);
char* KNHAPI KNH_SAFEFILE(char *file);

#ifdef __cplusplus
}
#endif

/* ======================================================================== */

#endif/*KONOHA_KNHAPI__H*/
