-/* -*-sod-*- */
+/* -*-sod-*- *
+ *
+ * Test program for Sod functionality
+ *
+ * (c) 2016 Straylight/Edgeware
+ */
+
+/*----- Licensing notice --------------------------------------------------*
+ *
+ * This file is part of the Sensible Object Design, an object system for C.
+ *
+ * SOD is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * SOD 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with SOD; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
code h: includes {
#include "sod.h"
}
-[link = SodObject, nick = t1base]
+[link = SodObject, nick = base]
class T1Base: SodObject {
[combination = progn] void aprogn();
[combination = sum] int asum();
struct vec avec();
}
-[link = T1Base, nick = t1mid]
+[link = T1Base, nick = mid]
class T1Mid: T1Base {
- void t1base.aprogn() { STEP(1); }
- int t1base.asum() { return 1; }
- int t1base.aand() { return 8; }
- int t1base.amax() { return 12; }
- struct item *t1base.alist() { return make_item("mid"); }
- int t1base.avec() { return 19; }
+ void base.aprogn() { STEP(1); }
+ int base.asum() { return 1; }
+ int base.aand() { return 8; }
+ int base.amax() { return 12; }
+ struct item *base.alist() { return make_item("mid"); }
+ int base.avec() { return 19; }
}
-[link = T1Mid, nick = t1sub]
+[link = T1Mid, nick = sub]
class T1Sub: T1Mid {
- void t1base.aprogn() { STEP(0); }
- int t1base.asum() { return 2; }
- int t1base.aand() { return 6; }
- int t1base.amax() { return 17; }
- struct item *t1base.alist() { return make_item("sub"); }
- int t1base.avec() { return 4; }
+ void base.aprogn() { STEP(0); }
+ int base.asum() { return 2; }
+ int base.aand() { return 6; }
+ int base.amax() { return 17; }
+ struct item *base.alist() { return make_item("sub"); }
+ int base.avec() { return 4; }
}
code c: tests {
STEP(0); T1Base_aprogn(t1); STEP(1);
if (T1Base_asum(t1) == 0) STEP(2);
if (T1Base_aand(t1) == 1) STEP(3);
- if (!t1->_vt->t1base.amax) STEP(4);
+ if (!t1->_vt->base.amax) STEP(4);
l = T1Base_alist(t1);
if (!l) STEP(5);
v = T1Base_avec(t1);
}
}
+/*----- Metaclass initialization ------------------------------------------*/
+
+[link = SodClass, nick = mycls]
+class MyClass: SodClass {
+ int x = -1, y, z = 2;
+}
+
+[link = SodObject, nick = myobj, metaclass = MyClass]
+class MyObject: SodObject {
+ class mycls.x = 0, mycls.y = 1;
+}
+
+code c: tests {
+ prepare("metaclass, init");
+ STEP(MyObject__cls_obj->mycls.x);
+ STEP(MyObject__cls_obj->mycls.y);
+ STEP(MyObject__cls_obj->mycls.z);
+ DONE(3);
+}
+
/*----- That's all, folks -------------------------------------------------*/