Skip to content

Commit

Permalink
Fixed several bugs and worked around bugs in Golo compiler so that it…
Browse files Browse the repository at this point in the history
… compiles with Golo 3.3 final release
  • Loading branch information
vvdleun committed May 14, 2019
1 parent 3f61ab6 commit 8b97220
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 22 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ repositories {
}

mainClassName = 'audiostreamerscrobbler.Audiostreamerscrobbler'
ext.goloDependency = 'org.eclipse.golo:golo:3.3.0-M1'
ext.goloDependency = 'org.eclipse.golo:golo:3.3.0'

dependencies {
golo goloDependency
Expand Down
2 changes: 1 addition & 1 deletion src/main/golo/include/maintypes/Song.golo
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module audiostreamerscrobbler.maintypes.Song
module audiostreamerscrobbler.maintypes.SongType

struct Song = {
name,
Expand Down
2 changes: 1 addition & 1 deletion src/main/golo/include/players/bluos/BluOsMonitor.golo
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module audiostreamerscrobbler.players.bluos.BluOsMonitor

import audiostreamerscrobbler.maintypes.Song.types.Song
import audiostreamerscrobbler.maintypes.SongType.types.Song
import audiostreamerscrobbler.players.bluos.BluOsStatusXMLParser
import audiostreamerscrobbler.players.helpers.PollBasedMonitorHelper
import audiostreamerscrobbler.threads.PlayerMonitorThreadTypes.types.MonitorThreadTypes
Expand Down
4 changes: 2 additions & 2 deletions src/main/golo/include/players/bluos/BluOsStatusXMLParser.golo
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module audiostreamerscrobbler.players.bluos.BluOsStatusXMLParser

import nl.vincentvanderleun.scrobbler.bluos.BluOsStatusXMLParser
import nl.vincentvanderleun.scrobbler.bluos.BluOsStatusXMLParserImpl

struct BluOsStatus = {
success,
Expand All @@ -15,7 +15,7 @@ struct BluOsStatus = {
}

function createBluOsStatusXMLParser = {
let bluOsStatusParser = BluOsStatusXMLParser()
let bluOsStatusParser = BluOsStatusXMLParserImpl()

let parser = DynamicObject("BluOsStatusXMLParser"):
define("_bluOsStatusParser", bluOsStatusParser):
Expand Down
2 changes: 1 addition & 1 deletion src/main/golo/include/players/heos/HeosSlaveMonitor.golo
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module audiostreamerscrobbler.players.heos.HeosSlaveMonitor

import audiostreamerscrobbler.maintypes.Song
import audiostreamerscrobbler.maintypes.SongType.types.Song
import audiostreamerscrobbler.players.heos.HeosConnectionSingleton
import audiostreamerscrobbler.threads.PlayerMonitorThreadTypes.types.MonitorThreadTypes
import audiostreamerscrobbler.utils.ThreadUtils
Expand Down
12 changes: 8 additions & 4 deletions src/main/golo/include/players/musiccast/MusicCastMonitor.golo
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module audiostreamerscrobbler.players.musiccast.MusicCastMonitor

import audiostreamerscrobbler.maintypes.{AppMetadata, Song}
import audiostreamerscrobbler.maintypes.AppMetadata
import audiostreamerscrobbler.maintypes.SongType.types.Song
import audiostreamerscrobbler.threads.PlayerMonitorThreadTypes.types.MonitorThreadTypes
import audiostreamerscrobbler.utils.{NetworkUtils, UrlUtils, ThreadUtils}

Expand Down Expand Up @@ -76,13 +77,16 @@ local function _createAndRunThread = |monitor| {
let status = JSON.parse(statusString)

let netUsbStatus = status: get("netusb")
# println(netUsbStatus)
if (netUsbStatus isnt null) {
var song = null
if (netUsbStatus: containsKey("play_info_updated")) {
song = getAndRegisterCurrentStatus(monitor)
} else if (netUsbStatus: containsKey("play_time")) {
song = monitor: _song()
song: position(netUsbStatus: get("play_time"): intValue())
if(song isnt null) {
song: position(netUsbStatus: get("play_time"): intValue())
}
}

# Inform MonitorThread about status
Expand Down Expand Up @@ -143,6 +147,7 @@ local function getAndRegisterCurrentStatus = |monitor| {
monitor: _song(song)
return song
} catch (ex) {
throw(ex)
monitor: _lastSuccess(false)
}
return null
Expand Down Expand Up @@ -178,11 +183,10 @@ local function isPlayerPlaying = |playInfo| {
}

local function convertPlayInfoToSong = |playInfo| {
let song = Song(
return Song(
playInfo: get("track"),
playInfo: get("artist"),
playInfo: get("album"),
playInfo: get("play_time"): intValue(),
playInfo: get("total_time"): intValue())
return song
}
4 changes: 2 additions & 2 deletions src/main/golo/include/threads/PlayerMonitorThread.golo
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module audiostreamerscrobbler.threads.PlayerMonitorThread

import audiostreamerscrobbler.maintypes.Song
import audiostreamerscrobbler.maintypes.SongType

import java.time.{Duration, Instant}

Expand Down Expand Up @@ -89,7 +89,7 @@ local function monitorCallback = |monitorThread, monitorState| {
}

local function handleMonitorState = |monitorThread, monitorState| {
var action = monitorAction.NoAction()
var action = MonitorStateActions.NoAction()
case {
when monitorState: isMonitoring() {
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/golo/include/utils/SimpleXMLParser.golo
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module audiostreamerscrobbler.utils.SimpleXMLParser

import nl.vincentvanderleun.utils.SimpleXMLParser
import nl.vincentvanderleun.utils.SimpleXMLParserImpl
import nl.vincentvanderleun.utils.SimpleXMLParserCallback

import gololang.Adapters
Expand All @@ -12,7 +12,7 @@ union events = {
}

function createSimpleXMLParser = {
let xmlParser = SimpleXMLParser()
let xmlParser = SimpleXMLParserImpl()

let parser = DynamicObject("SimpleXMLParser"):
define("_xmlParser", xmlParser):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;

public class BluOsStatusXMLParser {
public class BluOsStatusXMLParserImpl {
private static final Set<String> STATUS_XML_ELEMENTS = new HashSet<>();

private final SAXParser saxParser;
Expand All @@ -31,7 +31,7 @@ public class BluOsStatusXMLParser {
STATUS_XML_ELEMENTS.add("totlen");
}

public BluOsStatusXMLParser() {
public BluOsStatusXMLParserImpl() {
try {
SAXParserFactory factory = SAXParserFactory.newInstance();
saxParser = factory.newSAXParser();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;

public class SimpleXMLParser {
public class SimpleXMLParserImpl {
private final SAXParser saxParser;

public SimpleXMLParser() {
public SimpleXMLParserImpl() {
try {
SAXParserFactory parserFactory = SAXParserFactory.newInstance();
this.saxParser = parserFactory.newSAXParser();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
import org.junit.Before;
import org.junit.Test;

public class BluOsStatusXMLParserTests {
private BluOsStatusXMLParser bluOsStatusXMLParser;
public class BluOsStatusXMLParserImplTests {
private BluOsStatusXMLParserImpl bluOsStatusXMLParserImpl;

String BLUOS_STATUS_XML_DATA = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\r\n" +
"<status etag=\"7f41bde69dfcfd2dcbfd8dd90750cb37\">\r\n" +
Expand Down Expand Up @@ -48,14 +48,14 @@ public class BluOsStatusXMLParserTests {

@Before
public void init() {
bluOsStatusXMLParser = new BluOsStatusXMLParser();
bluOsStatusXMLParserImpl = new BluOsStatusXMLParserImpl();
}

@Test
public void mustParseBluOsStatusXML() throws IOException {
ByteArrayInputStream inputStream = new ByteArrayInputStream(BLUOS_STATUS_XML_DATA.getBytes());

BluOsParsedStatus status = bluOsStatusXMLParser.parse(inputStream);
BluOsParsedStatus status = bluOsStatusXMLParserImpl.parse(inputStream);

assertEquals("The Voice Of Love", status.getAlbum());
assertEquals("Julee Cruise", status.getArtist());
Expand Down

0 comments on commit 8b97220

Please sign in to comment.