sweet-moon 0.0.1 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,23 +9,26 @@ module Component
9
9
  Function = {
10
10
  push!: ->(api, state, closure) {
11
11
  handler = ->(current_state) {
12
- input = Reader[:read_all!].(api, current_state)
12
+ updated_state = state.merge(lua: current_state)
13
+ input = Reader[:read_all!].(api, updated_state)
13
14
  result = closure.(*input)
14
- Writer[:push!].(api, current_state, result)
15
+ Writer[:push!].(api, updated_state, result)
15
16
  return 1
16
17
  }
17
18
 
18
- api.lua_pushcclosure(state, handler, 0)
19
+ state[:avoid_gc] << handler
20
+
21
+ api.lua_pushcclosure(state[:lua], handler, 0)
19
22
  },
20
23
 
21
24
  read!: ->(api, state, _stack_index) {
22
25
  reference = api.luaL_ref(
23
- state, Logic::V51::Interpreter[:LUA_REGISTRYINDEX]
26
+ state[:lua], Logic::V51::Interpreter[:LUA_REGISTRYINDEX]
24
27
  )
25
28
 
26
29
  { value: ->(input = [], output = 1) {
27
30
  api.lua_rawgeti(
28
- state, Logic::V51::Interpreter[:LUA_REGISTRYINDEX], reference
31
+ state[:lua], Logic::V51::Interpreter[:LUA_REGISTRYINDEX], reference
29
32
  )
30
33
 
31
34
  input.each do |value|
@@ -11,27 +11,33 @@ module Component
11
11
 
12
12
  create_state!: ->(api) {
13
13
  state = api.luaL_newstate
14
- { state: state, error: state ? nil : :MemoryAllocation }
14
+ { state: { lua: state, avoid_gc: [] },
15
+ error: state ? nil : :MemoryAllocation }
15
16
  },
16
17
 
17
18
  open_standard_libraries!: ->(api, state) {
18
- api.luaL_openlibs(state)
19
+ api.luaL_openlibs(state[:lua])
19
20
 
20
21
  { state: state }
21
22
  },
22
23
 
23
24
  load_file_and_push_chunck!: ->(api, state, path) {
24
- result = api.luaL_loadfile(state, path)
25
+ result = api.luaL_loadfile(state[:lua], path)
25
26
  { state: state, error: Interpreter[:_error].(api, state, result, pull: true) }
26
27
  },
27
28
 
28
29
  push_chunk!: ->(api, state, value) {
29
- result = api.luaL_loadstring(state, value)
30
+ result = api.luaL_loadstring(state[:lua], value)
30
31
  { state: state, error: Interpreter[:_error].(api, state, result, pull: true) }
31
32
  },
32
33
 
33
- set_table!: ->(api, state, variable, value) {
34
- Table[:set!].(api, state, variable, value)
34
+ set_table!: ->(api, state) {
35
+ result = api.lua_settable(state[:lua], -3)
36
+
37
+ api.lua_settop(state[:lua], -2)
38
+
39
+ { state: state,
40
+ error: Interpreter[:_error].(api, state, result, pull: false) }
35
41
  },
36
42
 
37
43
  push_value!: ->(api, state, value) {
@@ -40,37 +46,38 @@ module Component
40
46
  },
41
47
 
42
48
  pop_and_set_as!: ->(api, state, variable) {
43
- api.lua_pushstring(state, variable)
44
- api.lua_insert(state, -2)
45
- api.lua_settable(state, Logic::V51::Interpreter[:LUA_GLOBALSINDEX])
49
+ api.lua_pushstring(state[:lua], variable)
50
+ api.lua_insert(state[:lua], -2)
51
+ api.lua_settable(state[:lua], Logic::V51::Interpreter[:LUA_GLOBALSINDEX])
46
52
  { state: state }
47
53
  },
48
54
 
49
55
  get_variable_and_push!: ->(api, state, variable, key = nil) {
50
- api.lua_pushstring(state, variable.to_s)
51
- api.lua_gettable(state, Logic::V51::Interpreter[:LUA_GLOBALSINDEX])
56
+ api.lua_pushstring(state[:lua], variable.to_s)
57
+ api.lua_gettable(state[:lua], Logic::V51::Interpreter[:LUA_GLOBALSINDEX])
52
58
 
53
59
  unless key.nil?
54
- if api.lua_typename(state, api.lua_type(state, -1)).read_string == 'table'
60
+ if api.lua_typename(state[:lua],
61
+ api.lua_type(state[:lua], -1)).read_string == 'table'
55
62
  Table[:read_field!].(api, state, key, -1)
56
63
  else
57
- api.lua_pushnil(state)
64
+ api.lua_pushnil(state[:lua])
58
65
  end
59
66
  end
60
67
 
61
- { state: state }
68
+ { state: state, extra_pop: true }
62
69
  },
63
70
 
64
71
  call!: ->(api, state, inputs = 0, outputs = 1) {
65
- result = api.lua_pcall(state, inputs, outputs, 0)
72
+ result = api.lua_pcall(state[:lua], inputs, outputs, 0)
66
73
  { state: state, error: Interpreter[:_error].(api, state, result, pull: true) }
67
74
  },
68
75
 
69
76
  read_and_pop!: ->(api, state, stack_index = -1, extra_pop: false) {
70
77
  result = Component::V51::Reader[:read!].(api, state, stack_index)
71
78
 
72
- api.lua_settop(state, -2) if result[:pop]
73
- api.lua_settop(state, -2) if extra_pop
79
+ api.lua_settop(state[:lua], -2) if result[:pop]
80
+ api.lua_settop(state[:lua], -2) if extra_pop
74
81
 
75
82
  { state: state, output: result[:value] }
76
83
  },
@@ -82,9 +89,12 @@ module Component
82
89
  },
83
90
 
84
91
  destroy_state!: ->(api, state) {
85
- result = api.lua_close(state)
92
+ result = api.lua_close(state[:lua])
93
+
94
+ state.delete(:lua)
95
+ state.delete(:avoid_gc)
86
96
 
87
- { state: nil, error: Interpreter[:_error].(api, state, result) }
97
+ { state: nil, error: Interpreter[:_error].(api, nil, result) }
88
98
  },
89
99
 
90
100
  _error: ->(api, state, code, options = {}) {
@@ -93,7 +103,7 @@ module Component
93
103
  ] || :error
94
104
 
95
105
  if code.is_a?(Numeric) && code >= 2
96
- return { status: status } unless options[:pull]
106
+ return { status: status } unless options[:pull] && state
97
107
 
98
108
  { status: status,
99
109
  value: Interpreter[:read_and_pop!].(api, state, -1)[:output] }
@@ -8,15 +8,16 @@ module Component
8
8
  module V51
9
9
  Reader = {
10
10
  read_all!: ->(api, state) {
11
- (1..api.lua_gettop(state)).map do
11
+ (1..api.lua_gettop(state[:lua])).map do
12
12
  Interpreter[:read_and_pop!].(api, state)[:output]
13
13
  end.reverse
14
14
  },
15
15
 
16
16
  read!: ->(api, state, stack_index = -1) {
17
- stack_index = api.lua_gettop(state) if stack_index == -1
17
+ stack_index = api.lua_gettop(state[:lua]) if stack_index == -1
18
18
 
19
- type = api.lua_typename(state, api.lua_type(state, stack_index)).read_string
19
+ type = api.lua_typename(state[:lua],
20
+ api.lua_type(state[:lua], stack_index)).read_string
20
21
 
21
22
  case type
22
23
  when 'string'
@@ -36,29 +37,30 @@ module Component
36
37
  else
37
38
  # none nil boolean lightuserdata number
38
39
  # string table function userdata thread
39
- { value: "#{type}: 0x#{api.lua_topointer(state, stack_index).address}",
40
+ { value:
41
+ "#{type}: 0x#{api.lua_topointer(state[:lua], stack_index).address}",
40
42
  type: type, pop: true }
41
43
  end
42
44
  },
43
45
 
44
46
  read_string!: ->(api, state, stack_index) {
45
- { value: api.lua_tostring(state, stack_index).read_string,
47
+ { value: api.lua_tostring(state[:lua], stack_index).read_string,
46
48
  pop: true }
47
49
  },
48
50
 
49
51
  read_number!: ->(api, state, stack_index) {
50
52
  if api.respond_to?(:lua_isinteger) &&
51
53
  api.respond_to?(:lua_tointeger) &&
52
- api.lua_isinteger(state, stack_index) == 1
54
+ api.lua_isinteger(state[:lua], stack_index) == 1
53
55
 
54
- return { value: api.lua_tointeger(state, stack_index), pop: true }
56
+ return { value: api.lua_tointeger(state[:lua], stack_index), pop: true }
55
57
  end
56
58
 
57
- { value: api.lua_tonumber(state, stack_index), pop: true }
59
+ { value: api.lua_tonumber(state[:lua], stack_index), pop: true }
58
60
  },
59
61
 
60
62
  read_boolean!: ->(api, state, stack_index) {
61
- { value: api.lua_toboolean(state, stack_index) == 1, pop: true }
63
+ { value: api.lua_toboolean(state[:lua], stack_index) == 1, pop: true }
62
64
  }
63
65
  }
64
66
  end
@@ -7,44 +7,45 @@ module Component
7
7
  module V51
8
8
  Table = {
9
9
  push!: ->(api, state, list, stack_index = -1) {
10
- stack_index = api.lua_gettop(state) if stack_index == -1
10
+ stack_index = api.lua_gettop(state[:lua]) if stack_index == -1
11
11
 
12
- api.lua_createtable(state, list.size, 0)
12
+ api.lua_createtable(state[:lua], list.size, 0)
13
13
 
14
14
  if list.is_a? Hash
15
15
  list.each_key do |key|
16
16
  Writer[:push!].(api, state, key)
17
17
  Writer[:push!].(api, state, list[key])
18
- api.lua_settable(state, stack_index + 1)
18
+ api.lua_settable(state[:lua], stack_index + 1)
19
19
  end
20
20
  else
21
21
  list.each_with_index do |value, index|
22
22
  Writer[:push!].(api, state, index + 1)
23
23
  Writer[:push!].(api, state, value)
24
- api.lua_settable(state, stack_index + 1)
24
+ api.lua_settable(state[:lua], stack_index + 1)
25
25
  end
26
26
  end
27
27
  },
28
28
 
29
29
  read!: ->(api, state, stack_index) {
30
- stack_index = api.lua_gettop(state) if stack_index == -1
30
+ stack_index = api.lua_gettop(state[:lua]) if stack_index == -1
31
31
 
32
- type = api.lua_typename(state, api.lua_type(state, stack_index)).read_string
32
+ type = api.lua_typename(state[:lua],
33
+ api.lua_type(state[:lua], stack_index)).read_string
33
34
 
34
- api.lua_pushnil(state)
35
+ api.lua_pushnil(state[:lua])
35
36
 
36
37
  return nil if type != 'table'
37
38
 
38
39
  tuples = []
39
40
 
40
- while api.lua_next(state, stack_index).positive?
41
+ while api.lua_next(state[:lua], stack_index).positive?
41
42
  value = Reader[:read!].(api, state, stack_index + 2)
42
43
  key = Reader[:read!].(api, state, stack_index + 1)
43
- api.lua_settop(state, -2) if value[:pop]
44
+ api.lua_settop(state[:lua], -2) if value[:pop]
44
45
 
45
46
  tuples << [key[:value], value[:value]]
46
47
 
47
- break if value[:type] == 'no value'
48
+ break if value[:type] == 'no value' || key[:value].instance_of?(Proc)
48
49
  end
49
50
 
50
51
  { value: Logic::Tables[:to_hash_or_array].(tuples), pop: true }
@@ -53,7 +54,7 @@ module Component
53
54
  read_field!: ->(api, state, expected_key, stack_index) {
54
55
  expected_key = expected_key.to_s if expected_key.is_a? Symbol
55
56
 
56
- api.lua_getfield(state, stack_index, expected_key)
57
+ api.lua_getfield(state[:lua], stack_index, expected_key)
57
58
  }
58
59
  }
59
60
  end
@@ -7,26 +7,26 @@ module Component
7
7
  push!: ->(api, state, value) {
8
8
  case Writer[:_to_lua_type].(value)
9
9
  when 'string'
10
- api.lua_pushstring(state, value.to_s)
10
+ api.lua_pushstring(state[:lua], value.to_s)
11
11
  when 'number'
12
- api.lua_pushnumber(state, value)
12
+ api.lua_pushnumber(state[:lua], value)
13
13
  when 'integer'
14
14
  if api.respond_to? :lua_pushinteger
15
- api.lua_pushinteger(state, value)
15
+ api.lua_pushinteger(state[:lua], value)
16
16
  else
17
- api.lua_pushnumber(state, value)
17
+ api.lua_pushnumber(state[:lua], value)
18
18
  end
19
19
  when 'nil'
20
- api.lua_pushnil(state)
20
+ api.lua_pushnil(state[:lua])
21
21
  when 'boolean'
22
- api.lua_pushboolean(state, value ? 1 : 0)
22
+ api.lua_pushboolean(state[:lua], value ? 1 : 0)
23
23
  when 'table'
24
24
  Table[:push!].(api, state, value)
25
25
  when 'function'
26
26
  Function[:push!].(api, state, value)
27
27
  else
28
28
  api.lua_pushstring(
29
- state, "#<#{value.class}:0x#{format('%016x', value.object_id)}>"
29
+ state[:lua], "#<#{value.class}:0x#{format('%016x', value.object_id)}>"
30
30
  )
31
31
  end
32
32
  },
@@ -9,23 +9,26 @@ module Component
9
9
  Function = {
10
10
  push!: ->(api, state, closure) {
11
11
  handler = ->(current_state) {
12
- input = Reader[:read_all!].(api, current_state)
12
+ updated_state = state.merge(lua: current_state)
13
+ input = Reader[:read_all!].(api, updated_state)
13
14
  result = closure.(*input)
14
- Writer[:push!].(api, current_state, result)
15
+ Writer[:push!].(api, updated_state, result)
15
16
  return 1
16
17
  }
17
18
 
18
- api.lua_pushcclosure(state, handler, 0)
19
+ state[:avoid_gc] << handler
20
+
21
+ api.lua_pushcclosure(state[:lua], handler, 0)
19
22
  },
20
23
 
21
24
  read!: ->(api, state, _stack_index) {
22
25
  reference = api.luaL_ref(
23
- state, Logic::V54::Interpreter[:LUA_REGISTRYINDEX]
26
+ state[:lua], Logic::V54::Interpreter[:LUA_REGISTRYINDEX]
24
27
  )
25
28
 
26
29
  { value: ->(input = [], output = 1) {
27
30
  api.lua_rawgeti(
28
- state, Logic::V54::Interpreter[:LUA_REGISTRYINDEX], reference
31
+ state[:lua], Logic::V54::Interpreter[:LUA_REGISTRYINDEX], reference
29
32
  )
30
33
 
31
34
  input.each do |value|
@@ -11,26 +11,32 @@ module Component
11
11
 
12
12
  create_state!: ->(api) {
13
13
  state = api.luaL_newstate
14
- { state: state, error: state ? nil : :MemoryAllocation }
14
+ { state: { lua: state, avoid_gc: [] },
15
+ error: state ? nil : :MemoryAllocation }
15
16
  },
16
17
 
17
18
  open_standard_libraries!: ->(api, state) {
18
- api.luaL_openlibs(state)
19
+ api.luaL_openlibs(state[:lua])
19
20
  { state: state }
20
21
  },
21
22
 
22
23
  load_file_and_push_chunck!: ->(api, state, path) {
23
- result = api.luaL_loadfile(state, path)
24
+ result = api.luaL_loadfile(state[:lua], path)
24
25
  { state: state, error: Interpreter[:_error].(api, state, result, pull: true) }
25
26
  },
26
27
 
27
28
  push_chunk!: ->(api, state, value) {
28
- result = api.luaL_loadstring(state, value)
29
+ result = api.luaL_loadstring(state[:lua], value)
29
30
  { state: state, error: Interpreter[:_error].(api, state, result, pull: true) }
30
31
  },
31
32
 
32
- set_table!: ->(api, state, variable, value) {
33
- Table[:set!].(api, state, variable, value)
33
+ set_table!: ->(api, state) {
34
+ result = api.lua_settable(state[:lua], -3)
35
+
36
+ api.lua_settop(state[:lua], -2)
37
+
38
+ { state: state,
39
+ error: Interpreter[:_error].(api, state, result, pull: false) }
34
40
  },
35
41
 
36
42
  push_value!: ->(api, state, value) {
@@ -39,34 +45,35 @@ module Component
39
45
  },
40
46
 
41
47
  pop_and_set_as!: ->(api, state, variable) {
42
- api.lua_setglobal(state, variable)
48
+ api.lua_setglobal(state[:lua], variable)
43
49
  { state: state }
44
50
  },
45
51
 
46
52
  get_variable_and_push!: ->(api, state, variable, key = nil) {
47
- api.lua_getglobal(state, variable.to_s)
53
+ api.lua_getglobal(state[:lua], variable.to_s)
48
54
 
49
55
  unless key.nil?
50
- if api.lua_typename(state, api.lua_type(state, -1)).read_string == 'table'
56
+ if api.lua_typename(state[:lua],
57
+ api.lua_type(state[:lua], -1)).read_string == 'table'
51
58
  Table[:read_field!].(api, state, key, -1)
52
59
  else
53
- api.lua_pushnil(state)
60
+ api.lua_pushnil(state[:lua])
54
61
  end
55
62
  end
56
63
 
57
- { state: state }
64
+ { state: state, extra_pop: true }
58
65
  },
59
66
 
60
67
  call!: ->(api, state, inputs = 0, outputs = 1) {
61
- result = api.lua_pcall(state, inputs, outputs, 0)
68
+ result = api.lua_pcall(state[:lua], inputs, outputs, 0)
62
69
  { state: state, error: Interpreter[:_error].(api, state, result, pull: true) }
63
70
  },
64
71
 
65
72
  read_and_pop!: ->(api, state, stack_index = -1, extra_pop: false) {
66
73
  result = Component::V54::Reader[:read!].(api, state, stack_index)
67
74
 
68
- api.lua_settop(state, -2) if result[:pop]
69
- api.lua_settop(state, -2) if extra_pop
75
+ api.lua_settop(state[:lua], -2) if result[:pop]
76
+ api.lua_settop(state[:lua], -2) if extra_pop
70
77
 
71
78
  { state: state, output: result[:value] }
72
79
  },
@@ -78,9 +85,12 @@ module Component
78
85
  },
79
86
 
80
87
  destroy_state!: ->(api, state) {
81
- result = api.lua_close(state)
88
+ result = api.lua_close(state[:lua])
89
+
90
+ state.delete(:lua)
91
+ state.delete(:avoid_gc)
82
92
 
83
- { state: nil, error: Interpreter[:_error].(api, state, result) }
93
+ { state: nil, error: Interpreter[:_error].(api, nil, result) }
84
94
  },
85
95
 
86
96
  _error: ->(api, state, code, options = {}) {
@@ -89,7 +99,7 @@ module Component
89
99
  ] || :error
90
100
 
91
101
  if code.is_a?(Numeric) && code >= 2
92
- return { status: status } unless options[:pull]
102
+ return { status: status } unless options[:pull] && state
93
103
 
94
104
  { status: status,
95
105
  value: Interpreter[:read_and_pop!].(api, state, -1)[:output] }
@@ -8,15 +8,16 @@ module Component
8
8
  module V54
9
9
  Reader = {
10
10
  read_all!: ->(api, state) {
11
- (1..api.lua_gettop(state)).map do
11
+ (1..api.lua_gettop(state[:lua])).map do
12
12
  Interpreter[:read_and_pop!].(api, state)[:output]
13
13
  end.reverse
14
14
  },
15
15
 
16
16
  read!: ->(api, state, stack_index = -1) {
17
- stack_index = api.lua_gettop(state) if stack_index == -1
17
+ stack_index = api.lua_gettop(state[:lua]) if stack_index == -1
18
18
 
19
- type = api.lua_typename(state, api.lua_type(state, stack_index)).read_string
19
+ type = api.lua_typename(state[:lua],
20
+ api.lua_type(state[:lua], stack_index)).read_string
20
21
 
21
22
  case type
22
23
  when 'string'
@@ -36,29 +37,30 @@ module Component
36
37
  else
37
38
  # none nil boolean lightuserdata number
38
39
  # string table function userdata thread
39
- { value: "#{type}: 0x#{api.lua_topointer(state, stack_index).address}",
40
+ { value:
41
+ "#{type}: 0x#{api.lua_topointer(state[:lua], stack_index).address}",
40
42
  type: type, pop: true }
41
43
  end
42
44
  },
43
45
 
44
46
  read_string!: ->(api, state, stack_index) {
45
- { value: api.lua_tostring(state, stack_index).read_string,
47
+ { value: api.lua_tostring(state[:lua], stack_index).read_string,
46
48
  pop: true }
47
49
  },
48
50
 
49
51
  read_number!: ->(api, state, stack_index) {
50
52
  if api.respond_to?(:lua_isinteger) &&
51
53
  api.respond_to?(:lua_tointeger) &&
52
- api.lua_isinteger(state, stack_index) == 1
54
+ api.lua_isinteger(state[:lua], stack_index) == 1
53
55
 
54
- return { value: api.lua_tointeger(state, stack_index), pop: true }
56
+ return { value: api.lua_tointeger(state[:lua], stack_index), pop: true }
55
57
  end
56
58
 
57
- { value: api.lua_tonumber(state, stack_index), pop: true }
59
+ { value: api.lua_tonumber(state[:lua], stack_index), pop: true }
58
60
  },
59
61
 
60
62
  read_boolean!: ->(api, state, stack_index) {
61
- { value: api.lua_toboolean(state, stack_index) == 1, pop: true }
63
+ { value: api.lua_toboolean(state[:lua], stack_index) == 1, pop: true }
62
64
  }
63
65
  }
64
66
  end
@@ -7,40 +7,41 @@ module Component
7
7
  module V54
8
8
  Table = {
9
9
  push!: ->(api, state, list, stack_index = -1) {
10
- stack_index = api.lua_gettop(state) if stack_index == -1
10
+ stack_index = api.lua_gettop(state[:lua]) if stack_index == -1
11
11
 
12
- api.lua_createtable(state, list.size, 0)
12
+ api.lua_createtable(state[:lua], list.size, 0)
13
13
 
14
14
  if list.is_a? Hash
15
15
  list.each_key do |key|
16
16
  Writer[:push!].(api, state, key)
17
17
  Writer[:push!].(api, state, list[key])
18
- api.lua_settable(state, stack_index + 1)
18
+ api.lua_settable(state[:lua], stack_index + 1)
19
19
  end
20
20
  else
21
21
  list.each_with_index do |value, index|
22
22
  Writer[:push!].(api, state, index + 1)
23
23
  Writer[:push!].(api, state, value)
24
- api.lua_settable(state, stack_index + 1)
24
+ api.lua_settable(state[:lua], stack_index + 1)
25
25
  end
26
26
  end
27
27
  },
28
28
 
29
29
  read!: ->(api, state, stack_index) {
30
- stack_index = api.lua_gettop(state) if stack_index == -1
30
+ stack_index = api.lua_gettop(state[:lua]) if stack_index == -1
31
31
 
32
- type = api.lua_typename(state, api.lua_type(state, stack_index)).read_string
32
+ type = api.lua_typename(state[:lua],
33
+ api.lua_type(state[:lua], stack_index)).read_string
33
34
 
34
- api.lua_pushnil(state)
35
+ api.lua_pushnil(state[:lua])
35
36
 
36
37
  return nil if type != 'table'
37
38
 
38
39
  tuples = []
39
40
 
40
- while api.lua_next(state, stack_index).positive?
41
+ while api.lua_next(state[:lua], stack_index).positive?
41
42
  value = Reader[:read!].(api, state, stack_index + 2)
42
43
  key = Reader[:read!].(api, state, stack_index + 1)
43
- api.lua_settop(state, -2) if value[:pop]
44
+ api.lua_settop(state[:lua], -2) if value[:pop]
44
45
 
45
46
  tuples << [key[:value], value[:value]]
46
47
 
@@ -53,7 +54,7 @@ module Component
53
54
  read_field!: ->(api, state, expected_key, stack_index) {
54
55
  expected_key = expected_key.to_s if expected_key.is_a? Symbol
55
56
 
56
- api.lua_getfield(state, stack_index, expected_key)
57
+ api.lua_getfield(state[:lua], stack_index, expected_key)
57
58
  }
58
59
  }
59
60
  end
@@ -7,26 +7,26 @@ module Component
7
7
  push!: ->(api, state, value) {
8
8
  case Writer[:_to_lua_type].(value)
9
9
  when 'string'
10
- api.lua_pushstring(state, value.to_s)
10
+ api.lua_pushstring(state[:lua], value.to_s)
11
11
  when 'number'
12
- api.lua_pushnumber(state, value)
12
+ api.lua_pushnumber(state[:lua], value)
13
13
  when 'integer'
14
14
  if api.respond_to? :lua_pushinteger
15
- api.lua_pushinteger(state, value)
15
+ api.lua_pushinteger(state[:lua], value)
16
16
  else
17
- api.lua_pushnumber(state, value)
17
+ api.lua_pushnumber(state[:lua], value)
18
18
  end
19
19
  when 'nil'
20
- api.lua_pushnil(state)
20
+ api.lua_pushnil(state[:lua])
21
21
  when 'boolean'
22
- api.lua_pushboolean(state, value ? 1 : 0)
22
+ api.lua_pushboolean(state[:lua], value ? 1 : 0)
23
23
  when 'table'
24
24
  Table[:push!].(api, state, value)
25
25
  when 'function'
26
26
  Function[:push!].(api, state, value)
27
27
  else
28
28
  api.lua_pushstring(
29
- state, "#<#{value.class}:0x#{format('%016x', value.object_id)}>"
29
+ state[:lua], "#<#{value.class}:0x#{format('%016x', value.object_id)}>"
30
30
  )
31
31
  end
32
32
  },
@@ -1,15 +1,58 @@
1
+ # Available at https://github.com/gbaptista/sweet-moon-test
2
+
3
+ fennel-dev: '/home/me/sweet-moon-test/fennel-dev.lua'
4
+
1
5
  luarocks:
2
- - /home/me/.luarocks/share/lua/5.4/?.lua
3
- - /home/me/.luarocks/share/lua/5.4/?/init.lua
4
- - /home/me/.luarocks/lib/lua/5.4/?.so
6
+ path:
7
+ - /home/me/.luarocks/share/lua/5.4/?.lua
8
+ - /home/me/.luarocks/share/lua/5.4/?/init.lua
9
+ - /home/me/.luarocks/lib/lua/5.4/?.so
10
+ expected: ['supernova', 'dkjson', 'lfs']
11
+
12
+ jit:2.0.5:
13
+ description: 'Lua Jit 2.0.5 + Fennel 1.0.0'
14
+ shared_object: /home/me/sweet-moon-test/libluajit.so.2.0.5
15
+ fennel: /home/me/sweet-moon-test/fennel-100.lua
5
16
 
6
17
  5.4.4:
7
18
  description: 'Lua 5.4.4 + Fennel 1.0.0'
8
- shared_object: /resources/liblua.so.5.4.4
9
- fennel: /resources/fennel.lua
19
+ shared_object: /home/me/sweet-moon-test/liblua.so.5.4.4
20
+ fennel: /home/me/sweet-moon-test/fennel-100.lua
21
+
22
+ 5.4.2:
23
+ description: 'Lua 5.4.2 + Fennel 1.0.0'
24
+ shared_object: /home/me/sweet-moon-test/liblua.so.5.4.2
25
+ fennel: /home/me/sweet-moon-test/fennel-100.lua
26
+
27
+ 5.3.3:
28
+ description: 'Lua 5.3.3'
29
+ shared_object: /home/me/sweet-moon-test/liblua.so.5.3.3
30
+ fennel: /home/me/sweet-moon-test/fennel-100.lua
31
+
32
+ 5.2.4:
33
+ description: 'Lua 5.2.4'
34
+ shared_object: /home/me/sweet-moon-test/liblua.so.5.2.4
35
+ fennel: /home/me/sweet-moon-test/fennel-100.lua
36
+
37
+ 5.1.5:
38
+ description: 'Lua 5.1.5'
39
+ shared_object: /home/me/sweet-moon-test/liblua.so.5.1.5
40
+ fennel: /home/me/sweet-moon-test/fennel-100.lua
41
+
42
+ 5.0.3:
43
+ description: 'Lua 5.0.3'
44
+ shared_object: /home/me/sweet-moon-test/liblua.so.5.0.3
10
45
 
11
46
  4.0.1:
12
47
  description: 'Lua 4.0.1'
13
48
  shared_objects:
14
- - /resources/liblua.so.4.0.1
15
- - /resources/liblualib.so.4.0.1
49
+ - /home/me/sweet-moon-test/liblua.so.4.0.1
50
+ - /home/me/sweet-moon-test/liblualib.so.4.0.1
51
+
52
+ 3.2.2:
53
+ description: 'Lua 3.2.2'
54
+ shared_object: /home/me/sweet-moon-test/liblua.so.3.2.2
55
+
56
+ '?':
57
+ description: 'Lua ?'
58
+ shared_object: /home/me/sweet-moon-test/liblua.so