Skip to content

Commit

Permalink
Merge pull request #203 from fsanaulla/issue-202
Browse files Browse the repository at this point in the history
[MACROS][ISSUE-202]: long type macro support
  • Loading branch information
fsanaulla authored Dec 18, 2019
2 parents af1bc06 + dc0b9c4 commit bb8c4bc
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
5 changes: 5 additions & 0 deletions changelog/0.6.3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Including issues:
- fsanaulla/chronicler#202 long type field support

Contributors:
- @fsanaulla
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ private[macros] final class InfluxImpl(val c: blackbox.Context) {
private[this] val tagsTypes =
Seq(getType[Option[String]], getType[String])
private[this] val fieldTypes =
Seq(getType[Boolean], getType[Int], getType[Double], getType[String], getType[Float])
Seq(getType[Boolean], getType[Int], getType[Double], getType[String], getType[Float], getType[Long])

private[this] def illegalArgExc(name: String): c.universe.Tree = {
val msg = s"Tag value can 't be empty string for tag: $name"
Expand Down Expand Up @@ -302,7 +302,7 @@ private[macros] final class InfluxImpl(val c: blackbox.Context) {
}
}

final class IntField(val key: Name, val value: Tree) extends Field {
final class IntOrLongField(val key: Name, val value: Tree) extends Field {
override def unquoted(head: Boolean): c.universe.Tree = {
val str =
if (head)
Expand Down Expand Up @@ -341,7 +341,7 @@ private[macros] final class InfluxImpl(val c: blackbox.Context) {
def isOption(tpe: c.universe.Type): Boolean =
tpe.typeConstructor =:= typeOf[Option[_]].typeConstructor
def isString(tpe: c.universe.Type): Boolean = tpe =:= string
def isInt(tpe: c.universe.Type): Boolean = tpe =:= int
def isIntOrLong(tpe: c.universe.Type): Boolean = tpe =:= int || tpe =:= long

/** Is it valid tag type */
def isTagType(tpe: c.universe.Type): Boolean =
Expand Down Expand Up @@ -424,8 +424,8 @@ private[macros] final class InfluxImpl(val c: blackbox.Context) {
val fields: List[Field] = fieldMethods map {
case m: MethodSymbol if isString(m.returnType) =>
new StringField(m.name, q"obj.${m.name}")
case m: MethodSymbol if isInt(m.returnType) =>
new IntField(m.name, q"obj.${m.name}")
case m: MethodSymbol if isIntOrLong(m.returnType) =>
new IntOrLongField(m.name, q"obj.${m.name}")
case m: MethodSymbol =>
new OtherField(m.name, q"obj.${m.name}")
}
Expand Down
2 changes: 1 addition & 1 deletion version.sbt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version in ThisBuild := "0.6.2"
version in ThisBuild := "0.6.3"

0 comments on commit bb8c4bc

Please sign in to comment.