From 312fc9175b80e65eb1f562a1cf69c1af38fafc2f Mon Sep 17 00:00:00 2001 From: antonkolotaev Date: Mon, 3 Feb 2014 16:55:14 +0100 Subject: [PATCH] first attempt to generate types --- marketsim/gen/_out/_types.py | 25 +++++++++++++++++++ marketsim/gen/_out/trash/types/_types.py | 4 +++ .../src/main/scala/generator/python/gen.scala | 19 ++++++++++++++ 3 files changed, 48 insertions(+) create mode 100644 marketsim/gen/_out/_types.py create mode 100644 marketsim/gen/_out/trash/types/_types.py diff --git a/marketsim/gen/_out/_types.py b/marketsim/gen/_out/_types.py new file mode 100644 index 00000000..c1f3bed6 --- /dev/null +++ b/marketsim/gen/_out/_types.py @@ -0,0 +1,25 @@ +#class ITrader(object): pass +#class IGraph(object): pass +#class CandleStick(object): pass +#class Volume(object,Int): pass +#class IAccount(object): pass +#class Side(object): pass +#class Boolean(object): pass +#class Price(object,Float): pass +#class IOrderQueue(object): pass +#class Float(object): pass +#class Int(object,Float): pass +#class ILink(object): pass +#class IOrderBook(object): pass +#class IEvent(object): pass +#class IMultiAssetStrategy(object): pass +#class ITwoWayLink(object): pass +#class ISingleAssetStrategy(object): pass +#class ISingleAssetTrader(object,IAccount,ITrader): pass +#class IVolumeLevels(object): pass +#class Order(object): pass +#class IDifferentiable(object,IFunction[Float]): pass +#class ITimeSerie(object): pass +#class Any(object): pass +#IOrderGenerator = IObservable[Order] +#class String(object): pass diff --git a/marketsim/gen/_out/trash/types/_types.py b/marketsim/gen/_out/trash/types/_types.py new file mode 100644 index 00000000..f950ffdb --- /dev/null +++ b/marketsim/gen/_out/trash/types/_types.py @@ -0,0 +1,4 @@ +#class T(object): pass +#class R(object,T): pass +#T1 = T +#class U(object,T,R): pass diff --git a/marketsim/gen/src/main/scala/generator/python/gen.scala b/marketsim/gen/src/main/scala/generator/python/gen.scala index 052fb420..a7340bea 100644 --- a/marketsim/gen/src/main/scala/generator/python/gen.scala +++ b/marketsim/gen/src/main/scala/generator/python/gen.scala @@ -68,6 +68,25 @@ package object gen } } + if (p.types.nonEmpty) + { + for (out <- managed(printWriter(dir, "_types.py"))) + { + p.types.values foreach { + case interface : Typed.InterfaceDecl => + if (interface.generics.isEmpty) { + val name = interface.name + val bases = interface.bases map { "," + _.toString } mkString "" + out.println(s"#class $name(object$bases): pass") + } + + case alias : Typed.AliasDecl => + if (alias.generics.isEmpty) + out.println("#" + alias.name + " = " + alias.target.toString) + } + } + } + p.functionAliases.values foreach { f => generationUnit(f.target) map { g => idx_out.println(base.withImports(Printer.importsOf(f.target).as(f.name)))