From 0826777503c0279a3ffe41e494c6b0490ec06779 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sat, 30 Apr 2016 15:45:26 +0100 Subject: Move Python runtime into correct package --- .../org/zwobble/couscous/backends/python/PythonBackend.java | 4 ++-- .../zwobble/couscous/backends/python/runtime/_couscous.py | 5 +++++ .../couscous/backends/python/runtime/java/lang/Integer.py | 13 +++++++++++++ .../couscous/backends/python/runtime/java/lang/Object.py | 1 + .../couscous/backends/python/runtime/java/lang/String.py | 2 ++ src/main/resources/python/runtime/_couscous.py | 5 ----- src/main/resources/python/runtime/java/lang/Integer.py | 13 ------------- src/main/resources/python/runtime/java/lang/Object.py | 1 - src/main/resources/python/runtime/java/lang/String.py | 2 -- 9 files changed, 23 insertions(+), 23 deletions(-) create mode 100644 src/main/resources/org/zwobble/couscous/backends/python/runtime/_couscous.py create mode 100644 src/main/resources/org/zwobble/couscous/backends/python/runtime/java/lang/Integer.py create mode 100644 src/main/resources/org/zwobble/couscous/backends/python/runtime/java/lang/Object.py create mode 100644 src/main/resources/org/zwobble/couscous/backends/python/runtime/java/lang/String.py delete mode 100644 src/main/resources/python/runtime/_couscous.py delete mode 100644 src/main/resources/python/runtime/java/lang/Integer.py delete mode 100644 src/main/resources/python/runtime/java/lang/Object.py delete mode 100644 src/main/resources/python/runtime/java/lang/String.py (limited to 'src') diff --git a/src/main/java/org/zwobble/couscous/backends/python/PythonBackend.java b/src/main/java/org/zwobble/couscous/backends/python/PythonBackend.java index b2aba24..a6c6772 100644 --- a/src/main/java/org/zwobble/couscous/backends/python/PythonBackend.java +++ b/src/main/java/org/zwobble/couscous/backends/python/PythonBackend.java @@ -40,7 +40,7 @@ public class PythonBackend implements Backend { String path = relativePathForModule(runtimeFile); writeModule( runtimeFile, - Resources.toString(Resources.getResource("python/runtime/" + path), StandardCharsets.UTF_8)); + Resources.toString(Resources.getResource("org/zwobble/couscous/backends/python/runtime/" + path), StandardCharsets.UTF_8)); } } @@ -74,4 +74,4 @@ public class PythonBackend implements Backend { packagePath = packagePath.getParent(); } } -} \ No newline at end of file +} diff --git a/src/main/resources/org/zwobble/couscous/backends/python/runtime/_couscous.py b/src/main/resources/org/zwobble/couscous/backends/python/runtime/_couscous.py new file mode 100644 index 0000000..6f3916c --- /dev/null +++ b/src/main/resources/org/zwobble/couscous/backends/python/runtime/_couscous.py @@ -0,0 +1,5 @@ +def _div_round_to_zero(a, b): + return -(-a // b) if (a < 0) ^ (b < 0) else a // b + +def _mod_round_to_zero(a, b): + return -(-a % b) if (a < 0) ^ (b < 0) else a % b diff --git a/src/main/resources/org/zwobble/couscous/backends/python/runtime/java/lang/Integer.py b/src/main/resources/org/zwobble/couscous/backends/python/runtime/java/lang/Integer.py new file mode 100644 index 0000000..48d6556 --- /dev/null +++ b/src/main/resources/org/zwobble/couscous/backends/python/runtime/java/lang/Integer.py @@ -0,0 +1,13 @@ +class Integer(object): + def __init__(self, value): + self._value = value + + def equals__Object__boolean(self, other): + # TODO: test this properly + return isinstance(other, Integer) and other._value == self._value + + def __str__(self): + return str(self._value) + + def __repr__(self): + return str(self) \ No newline at end of file diff --git a/src/main/resources/org/zwobble/couscous/backends/python/runtime/java/lang/Object.py b/src/main/resources/org/zwobble/couscous/backends/python/runtime/java/lang/Object.py new file mode 100644 index 0000000..29a8fba --- /dev/null +++ b/src/main/resources/org/zwobble/couscous/backends/python/runtime/java/lang/Object.py @@ -0,0 +1 @@ +Object = object diff --git a/src/main/resources/org/zwobble/couscous/backends/python/runtime/java/lang/String.py b/src/main/resources/org/zwobble/couscous/backends/python/runtime/java/lang/String.py new file mode 100644 index 0000000..9a1e025 --- /dev/null +++ b/src/main/resources/org/zwobble/couscous/backends/python/runtime/java/lang/String.py @@ -0,0 +1,2 @@ +class String(object): + pass \ No newline at end of file diff --git a/src/main/resources/python/runtime/_couscous.py b/src/main/resources/python/runtime/_couscous.py deleted file mode 100644 index 6f3916c..0000000 --- a/src/main/resources/python/runtime/_couscous.py +++ /dev/null @@ -1,5 +0,0 @@ -def _div_round_to_zero(a, b): - return -(-a // b) if (a < 0) ^ (b < 0) else a // b - -def _mod_round_to_zero(a, b): - return -(-a % b) if (a < 0) ^ (b < 0) else a % b diff --git a/src/main/resources/python/runtime/java/lang/Integer.py b/src/main/resources/python/runtime/java/lang/Integer.py deleted file mode 100644 index 48d6556..0000000 --- a/src/main/resources/python/runtime/java/lang/Integer.py +++ /dev/null @@ -1,13 +0,0 @@ -class Integer(object): - def __init__(self, value): - self._value = value - - def equals__Object__boolean(self, other): - # TODO: test this properly - return isinstance(other, Integer) and other._value == self._value - - def __str__(self): - return str(self._value) - - def __repr__(self): - return str(self) \ No newline at end of file diff --git a/src/main/resources/python/runtime/java/lang/Object.py b/src/main/resources/python/runtime/java/lang/Object.py deleted file mode 100644 index 29a8fba..0000000 --- a/src/main/resources/python/runtime/java/lang/Object.py +++ /dev/null @@ -1 +0,0 @@ -Object = object diff --git a/src/main/resources/python/runtime/java/lang/String.py b/src/main/resources/python/runtime/java/lang/String.py deleted file mode 100644 index 9a1e025..0000000 --- a/src/main/resources/python/runtime/java/lang/String.py +++ /dev/null @@ -1,2 +0,0 @@ -class String(object): - pass \ No newline at end of file -- cgit v1.2.3