comparison konoha.test/#test_glue.h# @ 16:5e36456a291c draft

add konoha.test
author Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
date Sun, 03 Jun 2012 01:38:13 +0900
parents
children
comparison
equal deleted inserted replaced
15:44e3247ed7c1 16:5e36456a291c
1 /****************************************************************************
2 * Copyright (c) 2012, the Konoha project authors. All rights reserved.
3 * Redistribution and use in source and binary forms, with or without
4 * modification, are permitted provided that the following conditions are met:
5 *
6 * * Redistributions of source code must retain the above copyright notice,
7 * this list of conditions and the following disclaimer.
8 * * Redistributions in binary form must reproduce the above copyright
9 * notice, this list of conditions and the following disclaimer in the
10 * documentation and/or other materials provided with the distribution.
11 *
12 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
13 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
14 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
15 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
16 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
17 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
18 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
19 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
20 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
21 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
22 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 ***************************************************************************/
24
25 #include<stdio.h>
26 #include<pthread.h>
27 #include<unistd.h>
28
29 #define Int_to(T, a) ((T)a.ivalue)
30 #define Float_to(T, a) ((T)a.fvalue)
31
32 static KMETHOD Test_print(CTX, ksfp_t *sfp _RIX)
33 {
34 if (Int_to(int, sfp[1]) < 1) {
35 RETURNi_(printf("test: sfp[1] < 1\n"));
36 } else {
37 RETURNi_(printf("test: sfp[1] > 1 \n"));
38 }
39 }
40
41
42 // --------------------------------------------------------------------------
43
44 #define _Public kMethod_Public
45 #define _Const kMethod_Const
46 #define _Coercion kMethod_Coercion
47 #define _F(F) (intptr_t)(F)
48 #define _KVf(T) "TEST_" #T, TY_Float, M_##T
49 #define TY_Test (cTest->cid)
50
51 static kbool_t test_initPackage(CTX, kKonohaSpace *ks, int argc, const char**args, kline_t pline)
52 {
53 static KDEFINE_CLASS TestDef = {
54 .structname = "Test"/*structname*/,
55 .cid = CLASS_newid/*cid*/,
56 };
57 kclass_t *cTest = Konoha_addClassDef(ks->packid, ks->packdom, NULL, &TestDef, pline);
58 int FN_x = FN_("x");
59 intptr_t MethodData[] = {
60 // ’´Ø’¿ô’¥Ý’¥¤’¥ó’¥¿, ’ÊÖ’¤ê’ÃÍ,this ’¤Î’·¿,’´Ø’¿ô’̾,’°ú’¿ô’¤Î’¿ô,’°ú’¿ô’¤Î’·¿,’°ú’¿ô’¤Î’̾’Á°...
61 // _P;ublicl_Const ’¤Ï Java ’¤Î annotation
62 _Public|_Const, _F(Test_print), TY_Int, TY_Test, MN_("print"), 1, TY_Int, FN_x,
63 // DEND ’¤Ç’¤ª’¤ï’¤ë
64 DEND,
65 };
66 // konoha ’¤Ø’¤Î’ÅÐ’Ï¿
67 kKonohaSpace_loadMethodData(ks, MethodData);
68
69 return true;
70 }
71
72 static kbool_t test_setupPackage(CTX, kKonohaSpace *ks, kline_t pline)
73 {
74 // ’º£’¤Ï’»È’¤Ã’¤Æ’¤Ê’¤¤’¤¬’¡¢’´ð’ËÜtrue
75 return true;
76 }
77
78 static kbool_t test_initKonohaSpace(CTX, kKonohaSpace *ks, kline_t pline)
79 {
80 // package ’¤Î’°Í’¸
81 return true;
82 }
83
84 static kbool_t test_setupKonohaSpace(CTX, kKonohaSpace *ks, kline_t pline)
85 {
86 // ’º£’¤Ï’»È’¤Ã’¤Æ’¤Ê’¤¤’¤¬,’´ð’ËÜtrue
87 return true;
88 }