Skip to content

Commit

Permalink
first attempt to generate types
Browse files Browse the repository at this point in the history
  • Loading branch information
antonkolotaev committed Feb 3, 2014
1 parent 3faf340 commit 312fc91
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
25 changes: 25 additions & 0 deletions marketsim/gen/_out/_types.py
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions marketsim/gen/_out/trash/types/_types.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#class T(object): pass
#class R(object,T): pass
#T1 = T
#class U(object,T,R): pass
19 changes: 19 additions & 0 deletions marketsim/gen/src/main/scala/generator/python/gen.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand Down

0 comments on commit 312fc91

Please sign in to comment.