changeset 540:4362eb720da9

add Number module
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 01 Jun 2015 18:04:50 -0600
parents 473e456444ff
children fda38db30e65
files core/src/luan/modules/Luan.luan core/src/luan/modules/Number.luan lucene/src/luan/modules/lucene/Lucene.luan lucene/src/luan/modules/lucene/Web_search.luan
diffstat 4 files changed, 22 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/core/src/luan/modules/Luan.luan	Mon Jun 01 17:53:55 2015 -0600
+++ b/core/src/luan/modules/Luan.luan	Mon Jun 01 18:04:50 2015 -0600
@@ -5,9 +5,6 @@
 
 M.assert_binary = BasicLuan.assert_binary
 M.assert_boolean = BasicLuan.assert_boolean
-M.assert_double = BasicLuan.assert_double
-M.assert_integer = BasicLuan.assert_integer
-M.assert_long = BasicLuan.assert_long
 M.assert_number = BasicLuan.assert_number
 M.assert_string = BasicLuan.assert_string
 M.assert_table = BasicLuan.assert_table
@@ -16,7 +13,6 @@
 M.load = BasicLuan.load
 M.load_file = BasicLuan.load_file
 M.new_error = BasicLuan.new_error
-M.number_type = BasicLuan.number_type
 M.pairs = BasicLuan.pairs
 M.pcall = BasicLuan.pcall
 M.range = BasicLuan.range
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/src/luan/modules/Number.luan	Mon Jun 01 18:04:50 2015 -0600
@@ -0,0 +1,11 @@
+java()
+local BasicLuan = require "java:luan.modules.BasicLuan"
+
+local M = {}
+
+M.double = BasicLuan.assert_double
+M.integer = BasicLuan.assert_integer
+M.long = BasicLuan.assert_long
+M.number_type = BasicLuan.number_type
+
+return M
--- a/lucene/src/luan/modules/lucene/Lucene.luan	Mon Jun 01 17:53:55 2015 -0600
+++ b/lucene/src/luan/modules/lucene/Lucene.luan	Mon Jun 01 18:04:50 2015 -0600
@@ -5,7 +5,10 @@
 local type = Luan.type
 local number_type = Luan.number_type
 local error = Luan.error
+local Number = require "luan:Number"
+local number_type = Number.number_type
 local Table = require "luan:Table"
+local unpack = Table.unpack
 local LuceneIndex = require "java:luan.modules.lucene.LuceneIndex"
 local Term = require "java:org.apache.lucene.index.Term"
 local TermQuery = require "java:org.apache.lucene.search.TermQuery"
@@ -163,7 +166,7 @@
 			local reverse = f.reverse or false
 			a[#a+1] = SortField.new(field,type,reverse)
 		end
-		return Sort.new(Table.unpack(a))
+		return Sort.new(unpack(a))
 	end
 
 
--- a/lucene/src/luan/modules/lucene/Web_search.luan	Mon Jun 01 17:53:55 2015 -0600
+++ b/lucene/src/luan/modules/lucene/Web_search.luan	Mon Jun 01 18:04:50 2015 -0600
@@ -1,12 +1,13 @@
 local Luan = require "luan:Luan"
-local assert_integer = Luan.assert_integer
-local assert_long = Luan.assert_long
-local assert_double = Luan.assert_double
 local load = Luan.load
 local pairs = Luan.pairs
 local ipairs = Luan.ipairs
 local range = Luan.range
 local to_string = Luan.to_string
+local Number = require "luan:Number"
+local integer = Number.integer
+local long = Number.long
+local double = Number.double
 local Io = require "luan:Io"
 local Http = require "luan:http/Http"
 local String = require "luan:String"
@@ -136,9 +137,9 @@
 		end
 		local query_env = {
 			query=index.query;
-			assert_integer=assert_integer;
-			assert_long=assert_long;
-			assert_double=assert_double;
+			integer=integer;
+			long=long;
+			double=double;
 		}
 		local query = load(query_string,"<query>",query_env,true)()
 		local rows = string_to_number(Http.request.parameter.rows)