Commit 6d6ca3d9 authored by Miro Knejp's avatar Miro Knejp

Add missing float suffix to cpp constants

parent 1330584c
...@@ -95,6 +95,7 @@ class CppGenerator(spec: Spec) extends Generator(spec) { ...@@ -95,6 +95,7 @@ class CppGenerator(spec: Spec) extends Generator(spec) {
def generateCppConstants(w: IndentWriter, consts: Seq[Const], selfName: String) = { def generateCppConstants(w: IndentWriter, consts: Seq[Const], selfName: String) = {
def writeCppConst(w: IndentWriter, ty: TypeRef, v: Any): Unit = v match { def writeCppConst(w: IndentWriter, ty: TypeRef, v: Any): Unit = v match {
case l: Long => w.w(l.toString) case l: Long => w.w(l.toString)
case d: Double if marshal.fieldType(ty) == "float" => w.w(d.toString + "f")
case d: Double => w.w(d.toString) case d: Double => w.w(d.toString)
case b: Boolean => w.w(if (b) "true" else "false") case b: Boolean => w.w(if (b) "true" else "false")
case s: String => w.w(s) case s: String => w.w(s)
......
...@@ -13,7 +13,7 @@ int32_t const Constants::I32_CONSTANT = 3; ...@@ -13,7 +13,7 @@ int32_t const Constants::I32_CONSTANT = 3;
int64_t const Constants::I64_CONSTANT = 4; int64_t const Constants::I64_CONSTANT = 4;
float const Constants::F32_CONSTANT = 5.0; float const Constants::F32_CONSTANT = 5.0f;
double const Constants::F64_CONSTANT = 5.0; double const Constants::F64_CONSTANT = 5.0;
......
...@@ -13,6 +13,6 @@ int32_t const ConstantsInterface::I32_CONSTANT = 3; ...@@ -13,6 +13,6 @@ int32_t const ConstantsInterface::I32_CONSTANT = 3;
int64_t const ConstantsInterface::I64_CONSTANT = 4; int64_t const ConstantsInterface::I64_CONSTANT = 4;
float const ConstantsInterface::F32_CONSTANT = 5.0; float const ConstantsInterface::F32_CONSTANT = 5.0f;
double const ConstantsInterface::F64_CONSTANT = 5.0; double const ConstantsInterface::F64_CONSTANT = 5.0;
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment