Exemplo n.º 1
0
def wrapfn(name, fn):
	global ccount
	ccount = ccount + 1
	sm = sym(name)
	cg = CodeGeneratorBackend()
	cg.begin()
	cg.writeln("from clojure.lang.afn import AFn")
	cg.writeln("class _WrapClass_" + str(ccount) + "(AFn):")
	cg.indent()
	argc = len(inspect.getargspec(fn))
	cg.writeln(get_invokedef(argc))
	cg.indent()
	cg.writeln(fn.__name__ + get_arglist(argc, None))
	cg.dedent()
	cg.dedent()
	cg.writeln("Var(Symbol.from_string(\""+name+"\"), _WrapClass_"+str(ccount)+"())")
	return cg.end()
Exemplo n.º 2
0
def with_meta(obj, m):
    return obj.assoc(sym("meta"), m)
Exemplo n.º 3
0
    def get(self, name):
        return self.registry.get(name)
    
    
_protocols = ProtocolRegistry()

class Protocol(Obj)
    def __init__(self, name, fns):
        self.name = name
        self.fns = fns
        _protocols.register(name, self)
		
def gen_type(name, args):
	fields = []
	for x in range(len(args)):
		fields.append(Symbol.intern(args[x]))
	return Type(Symbol.intern(name), fields)
	

def with_meta(obj, m):
    return obj.assoc(sym("meta"), m)

def list_conj(lst, itm):
    return     
		
list_type = gen_type("PersistentList", 
                     ["count", "first", "rest"]
                     {sym("cons"), )

def list_node(