Laurent MOULIN / Mbed 2 deprecated tinypy

Dependencies:   mbed

Committer:
gignops
Date:
Sun Oct 07 11:49:09 2012 +0000
Revision:
0:4ab1392a0142
This project is an adaptation of tinypy code. The aim is to run python code on Mbed.; ; Have fun !

Who changed what in which revision?

UserRevisionLine numberNew contents of line
gignops 0:4ab1392a0142 1 #ifndef OPS_H
gignops 0:4ab1392a0142 2 #define OPS_H
gignops 0:4ab1392a0142 3
gignops 0:4ab1392a0142 4 #include "tp.h"
gignops 0:4ab1392a0142 5 #include "dict.h"
gignops 0:4ab1392a0142 6 #include "list.h"
gignops 0:4ab1392a0142 7 #include "misc.h"
gignops 0:4ab1392a0142 8 #include "builtins.h"
gignops 0:4ab1392a0142 9
gignops 0:4ab1392a0142 10
gignops 0:4ab1392a0142 11 tp_obj tp_str(TP,tp_obj self);
gignops 0:4ab1392a0142 12 int tp_bool(TP,tp_obj v);
gignops 0:4ab1392a0142 13 tp_obj tp_has(TP,tp_obj self, tp_obj k);
gignops 0:4ab1392a0142 14 void tp_del(TP,tp_obj self, tp_obj k);
gignops 0:4ab1392a0142 15 tp_obj tp_iter(TP,tp_obj self, tp_obj k);
gignops 0:4ab1392a0142 16 tp_obj tp_get(TP,tp_obj self, tp_obj k);
gignops 0:4ab1392a0142 17 int tp_iget(TP,tp_obj *r, tp_obj self, tp_obj k);
gignops 0:4ab1392a0142 18 void tp_set(TP,tp_obj self, tp_obj k, tp_obj v);
gignops 0:4ab1392a0142 19 tp_obj tp_add(TP,tp_obj a, tp_obj b);
gignops 0:4ab1392a0142 20 tp_obj tp_mul(TP,tp_obj a, tp_obj b);
gignops 0:4ab1392a0142 21 tp_obj tp_len(TP,tp_obj self);
gignops 0:4ab1392a0142 22 int tp_cmp(TP,tp_obj a, tp_obj b);
gignops 0:4ab1392a0142 23
gignops 0:4ab1392a0142 24 #define TP_OP(name,expr) \
gignops 0:4ab1392a0142 25 tp_obj name(TP,tp_obj _a,tp_obj _b) { \
gignops 0:4ab1392a0142 26 if (_a.type == TP_NUMBER && _a.type == _b.type) { \
gignops 0:4ab1392a0142 27 tp_num a = _a.number.val; tp_num b = _b.number.val; \
gignops 0:4ab1392a0142 28 return tp_number(expr); \
gignops 0:4ab1392a0142 29 } \
gignops 0:4ab1392a0142 30 tp_raise(tp_None,"%s(%s,%s)",#name,TP_CSTR(_a),TP_CSTR(_b)); \
gignops 0:4ab1392a0142 31 }
gignops 0:4ab1392a0142 32
gignops 0:4ab1392a0142 33 tp_obj tp_and(TP,tp_obj _a,tp_obj _b);
gignops 0:4ab1392a0142 34 tp_obj tp_or(TP,tp_obj _a,tp_obj _b);
gignops 0:4ab1392a0142 35 tp_obj tp_mod(TP,tp_obj _a,tp_obj _b);
gignops 0:4ab1392a0142 36 tp_obj tp_lsh(TP,tp_obj _a,tp_obj _b);
gignops 0:4ab1392a0142 37 tp_obj tp_rsh(TP,tp_obj _a,tp_obj _b);
gignops 0:4ab1392a0142 38 tp_obj tp_sub(TP,tp_obj _a,tp_obj _b);
gignops 0:4ab1392a0142 39 tp_obj tp_div(TP,tp_obj _a,tp_obj _b);
gignops 0:4ab1392a0142 40 tp_obj tp_pow(TP,tp_obj _a,tp_obj _b);
gignops 0:4ab1392a0142 41
gignops 0:4ab1392a0142 42
gignops 0:4ab1392a0142 43 #endif