Skip to content

Commit

Permalink
computing precisely a set of Observable[T] to generate
Browse files Browse the repository at this point in the history
  • Loading branch information
antonkolotaev committed Feb 27, 2014
1 parent 681f8e4 commit 5e60132
Show file tree
Hide file tree
Showing 16 changed files with 52 additions and 44 deletions.
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
from marketsim.gen._out._ifunction._ifunctionfloat import IFunctionfloat
from marketsim.gen._out._ifunction._ifunctioniobservableiorderifunctionside import IFunctionIObservableIOrderIFunctionSide
from marketsim.gen._out._ifunction._ifunctioniobservableiorderifunctionsideifunctionfloat import IFunctionIObservableIOrderIFunctionSideIFunctionfloat
from marketsim import meta
#((() => .Float),(() => .Float)) => ((() => .Side) => .IObservable[.IOrder])
#(() => .Float) => (((() => .Side),(() => .Float)) => .IObservable[.IOrder])
class IFunctionIFunctionIObservableIOrderIFunctionSideIFunctionfloatIFunctionfloat(object):
_types = [meta.function((IFunctionfloat,IFunctionfloat,),IFunctionIObservableIOrderIFunctionSide)]
_types = [meta.function((IFunctionfloat,),IFunctionIObservableIOrderIFunctionSideIFunctionfloat)]

pass



from marketsim.gen._out._ifunction._ifunctionfloat import IFunctionfloat
from marketsim.gen._out._ifunction._ifunctioniobservableiorderifunctionsideifunctionfloat import IFunctionIObservableIOrderIFunctionSideIFunctionfloat
from marketsim.gen._out._ifunction._ifunctioniobservableiorderifunctionside import IFunctionIObservableIOrderIFunctionSide
from marketsim import meta
#(() => .Float) => (((() => .Side),(() => .Float)) => .IObservable[.IOrder])
#((() => .Float),(() => .Float)) => ((() => .Side) => .IObservable[.IOrder])
class IFunctionIFunctionIObservableIOrderIFunctionSideIFunctionfloatIFunctionfloat(object):
_types = [meta.function((IFunctionfloat,),IFunctionIObservableIOrderIFunctionSideIFunctionfloat)]
_types = [meta.function((IFunctionfloat,IFunctionfloat,),IFunctionIObservableIOrderIFunctionSide)]

pass

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
#((() => .Boolean),(() => .Float),.IObservable[.Float]) => .IObservable[.Float]
class IFunctionIObservablefloatIFunctionboolIFunctionfloatIObservablefloat(object):
_types = [meta.function((IFunctionbool,IFunctionfloat,IObservablefloat,),IObservablefloat)]
_types.append(IFunctionIObservablefloatIFunctionboolIObservablefloatIObservablefloat)
_types.append(IFunctionIObservablefloatIObservableboolIFunctionfloatIObservablefloat)
_types.append(IFunctionIObservablefloatIFunctionboolIObservablefloatIObservablefloat)
_types.append(IFunctionIObservablefloatIObservableboolIObservablefloatIObservablefloat)
pass

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
#(.IObservable[.Boolean],(() => .Float),(() => .Float)) => .IObservable[.Float]
class IFunctionIObservablefloatIObservableboolIFunctionfloatIFunctionfloat(object):
_types = [meta.function((IObservablebool,IFunctionfloat,IFunctionfloat,),IObservablefloat)]
_types.append(IFunctionIObservablefloatIObservableboolIObservablefloatIFunctionfloat)
_types.append(IFunctionIObservablefloatIObservableboolIFunctionfloatIObservablefloat)
_types.append(IFunctionIObservablefloatIObservableboolIObservablefloatIFunctionfloat)
_types.append(IFunctionIObservablefloatIObservableboolIObservablefloatIObservablefloat)
pass

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
#((() => .Boolean),(() => .Side),.IObservable[.Side]) => .IObservable[.Side]
class IFunctionIObservableSideIFunctionboolIFunctionSideIObservableSide(object):
_types = [meta.function((IFunctionbool,IFunctionSide,IObservableSide,),IObservableSide)]
_types.append(IFunctionIObservableSideIFunctionboolIObservableSideIObservableSide)
_types.append(IFunctionIObservableSideIObservableboolIFunctionSideIObservableSide)
_types.append(IFunctionIObservableSideIFunctionboolIObservableSideIObservableSide)
_types.append(IFunctionIObservableSideIObservableboolIObservableSideIObservableSide)
pass

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
#((() => .Boolean),.IObservable[.Side],(() => .Side)) => .IObservable[.Side]
class IFunctionIObservableSideIFunctionboolIObservableSideIFunctionSide(object):
_types = [meta.function((IFunctionbool,IObservableSide,IFunctionSide,),IObservableSide)]
_types.append(IFunctionIObservableSideIFunctionboolIObservableSideIObservableSide)
_types.append(IFunctionIObservableSideIObservableboolIObservableSideIFunctionSide)
_types.append(IFunctionIObservableSideIFunctionboolIObservableSideIObservableSide)
_types.append(IFunctionIObservableSideIObservableboolIObservableSideIObservableSide)
pass

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
#(.IObservable[.Boolean],(() => .Side),(() => .Side)) => .IObservable[.Side]
class IFunctionIObservableSideIObservableboolIFunctionSideIFunctionSide(object):
_types = [meta.function((IObservablebool,IFunctionSide,IFunctionSide,),IObservableSide)]
_types.append(IFunctionIObservableSideIObservableboolIObservableSideIFunctionSide)
_types.append(IFunctionIObservableSideIObservableboolIFunctionSideIObservableSide)
_types.append(IFunctionIObservableSideIObservableboolIObservableSideIFunctionSide)
_types.append(IFunctionIObservableSideIObservableboolIObservableSideIObservableSide)
pass

Expand Down
2 changes: 1 addition & 1 deletion marketsim/gen/_out/_ifunction/_ifunctionu.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
class IFunctionU(object):
_types = [meta.function((),U)]
_types.append(IFunctionobject)
_types.append(IFunctionR)
_types.append(IFunctionT)
_types.append(IFunctionR)
pass


Expand Down
3 changes: 2 additions & 1 deletion marketsim/gen/_out/_observable/_observablebool.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from marketsim.gen._out._iobservable._iobservablebool import IObservablebool
from marketsim.gen._out._observable._observableobject import Observableobject
from marketsim.event import Conditional_Impl
class Observablebool(Conditional_Impl, IObservablebool):
_types = []

_types.append(Observableobject)



3 changes: 2 additions & 1 deletion marketsim/gen/_out/_observable/_observablefloat.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from marketsim.gen._out._iobservable._iobservablefloat import IObservablefloat
from marketsim.gen._out._observable._observableobject import Observableobject
from marketsim.event import Conditional_Impl
class Observablefloat(Conditional_Impl, IObservablefloat):
_types = []

_types.append(Observableobject)



3 changes: 2 additions & 1 deletion marketsim/gen/_out/_observable/_observableicandlestick.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from marketsim.gen._out._icandlestick import ICandleStick
from marketsim.gen._out._iobservable._iobservableicandlestick import IObservableICandleStick
from marketsim.gen._out._observable._observableobject import Observableobject
from marketsim.event import Conditional_Impl
class ObservableICandleStick(Conditional_Impl, IObservableICandleStick):
_types = []

_types.append(Observableobject)



2 changes: 2 additions & 0 deletions marketsim/gen/_out/_observable/_observableint.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
from marketsim.gen._out._iobservable._iobservableint import IObservableint
from marketsim.gen._out._observable._observableobject import Observableobject
from marketsim.gen._out._observable._observablefloat import Observablefloat
from marketsim.event import Conditional_Impl
class Observableint(Conditional_Impl, IObservableint):
_types = []
_types.append(Observableobject)
_types.append(Observablefloat)


Expand Down
3 changes: 2 additions & 1 deletion marketsim/gen/_out/_observable/_observableiorder.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from marketsim.gen._out._iorder import IOrder
from marketsim.gen._out._iobservable._iobservableiorder import IObservableIOrder
from marketsim.gen._out._observable._observableobject import Observableobject
from marketsim.event import Conditional_Impl
class ObservableIOrder(Conditional_Impl, IObservableIOrder):
_types = []

_types.append(Observableobject)



3 changes: 2 additions & 1 deletion marketsim/gen/_out/_observable/_observableivolumelevels.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from marketsim.gen._out._ivolumelevels import IVolumeLevels
from marketsim.gen._out._iobservable._iobservableivolumelevels import IObservableIVolumeLevels
from marketsim.gen._out._observable._observableobject import Observableobject
from marketsim.event import Conditional_Impl
class ObservableIVolumeLevels(Conditional_Impl, IObservableIVolumeLevels):
_types = []

_types.append(Observableobject)



8 changes: 8 additions & 0 deletions marketsim/gen/_out/_observable/_observableobject.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from marketsim.gen._out._iobservable._iobservableobject import IObservableobject
from marketsim.event import Conditional_Impl
class Observableobject(Conditional_Impl, IObservableobject):
_types = []




3 changes: 2 additions & 1 deletion marketsim/gen/_out/_observable/_observableside.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from marketsim.gen._out._side import Side
from marketsim.gen._out._iobservable._iobservableside import IObservableSide
from marketsim.gen._out._observable._observableobject import Observableobject
from marketsim.event import Conditional_Impl
class ObservableSide(Conditional_Impl, IObservableSide):
_types = []

_types.append(Observableobject)



44 changes: 18 additions & 26 deletions marketsim/gen/src/main/scala/generator/python/gen.scala
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,24 @@ package object gen

ty_out.println(base.withImports(s).toString)
}
case f : TypesBound.Interface if f.decl.name == "Observable" =>
val rt = f.genericArgs(0)
val name = Printer.mangle(f.asCode.toString)

val casts = Code.from(
TypesBound.directCasts(f.genericArgs(0)).toList map { t =>
"_types.append(" ||| Typed.topLevel.observableImplOf(t).asCode ||| ")" },
predef.crlf)

for (ty_out <- managed(printWriter(new File(out_dir, "_observable"), s"_$name.py")))
{
val s =
s"class $name(Conditional_Impl, "||| Typed.topLevel.observableOf(rt).asCode |||"):" |>
("_types = []" | casts) | nl | ImportFrom("Conditional_Impl", "marketsim.event")

ty_out.println(base.withImports(s).toString)
}

case _ =>

}
Expand Down Expand Up @@ -242,32 +260,6 @@ package object gen

out.println(base.withImports(s).toString)

} else {
val base_dir = new File(s"$dir/_$name")

if (interface.name == "Observable") {

val fs = interface.getInstances

fs foreach { f =>

val rt = f.genericArgs(0)
val name = Printer.mangle(f.asCode.toString)

val casts = Code.from(
(fs filter { y => y != f && (f canCastTo y) } map { "_types.append(" ||| _.asCode ||| ")" }).toList,
predef.crlf)

for (ty_out <- managed(printWriter(base_dir, s"_$name.py")))
{
val s =
s"class $name(Conditional_Impl, "||| Typed.topLevel.observableOf(rt).asCode |||"):" |>
("_types = []" | casts) | nl | ImportFrom("Conditional_Impl", "marketsim.event")

ty_out.println(base.withImports(s).toString)
}
}
}
}
}

Expand Down

0 comments on commit 5e60132

Please sign in to comment.