~mildred/liworld/trunk

« back to all changes in this revision

Viewing changes to src/lua_cfunction.li

  • Committer: Mildred
  • Date: 2007-07-07 01:20:40 UTC
  • Revision ID: mildred593@online.fr-20070707012040-vqlc2w1j08q31nxc
Added Lua related objects
Adde few FAIL lines. It seems to happen on the slots at and put__to for
the HASHED_DICTIONART[V,K] object ... Maybe a bug in this object that
makes it loop forever
It compiles

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Section Header
 
2
 
 
3
  + name := LUA_CFUNCTION;
 
4
 
 
5
  - author        := "Mildred <mildred593(at)online.fr>";
 
6
  - bibliography  := "";
 
7
  - comment       := "";
 
8
 
 
9
  // Copyright (c) 2007 Mildred <mildred593(at)online.fr>
 
10
  //
 
11
  // Permission is hereby granted, free of charge, to any person
 
12
  // obtaining a copy of this software and associated documentation
 
13
  // files (the "Software"), to deal in the Software without
 
14
  // restriction, including without limitation the rights to use,
 
15
  // copy, modify, merge, publish, distribute, sublicense, and/or sell
 
16
  // copies of the Software, and to permit persons to whom the
 
17
  // Software is furnished to do so, subject to the following
 
18
  // conditions:
 
19
  //
 
20
  // The above copyright notice and this permission notice shall be
 
21
  // included in all copies or substantial portions of the Software.
 
22
  //
 
23
  // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 
24
  // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
 
25
  // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 
26
  // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 
27
  // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 
28
  // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 
29
  // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 
30
  // OTHER DEALINGS IN THE SOFTWARE.
 
31
 
 
32
  - external := `#define lisaac_call_lua_cfunction static lisaac_call_lua_cfunction0`;
 
33
 
 
34
Section Inherit
 
35
 
 
36
  - parent_object :OBJECT := OBJECT;
 
37
 
 
38
Section External
 
39
 
 
40
  - lisaac_call_lua_cfunction lua_p:POINTER :INTEGER <-
 
41
  (
 
42
    + res :INTEGER;
 
43
    (lua_p != NULL).if_true {
 
44
      + self :SELF;
 
45
      + lua :LUA_STATE;
 
46
      lua := LUA_STATE.create_import lua_p;
 
47
      self := CONVERT[POINTER, SELF].on
 
48
        (lua.touserdata (`lua_upvalueindex(1)`:INTEGER));
 
49
      res := self.call lua;
 
50
    };
 
51
    res
 
52
  );
 
53
 
 
54
Section Public
 
55
 
 
56
  - call_pointer lua_p:POINTER :INTEGER <-
 
57
  (
 
58
    + lua :LUA_STATE;
 
59
    lua := LUA_STATE.create_import lua_p;
 
60
    call lua
 
61
  );
 
62
 
 
63
  - call lua:LUA_STATE :INTEGER <- block.value lua;
 
64
 
 
65
Section Private
 
66
 
 
67
  + block :BLOCK :=
 
68
  { lua:LUA_STATE;
 
69
    lua.is_valid.if_false {
 
70
      crash_with_message "Lua call of the default C function.";
 
71
    };
 
72
    0
 
73
  };
 
74
 
 
75
  - creator_of_lua_cfunctions :INTEGER := lisaac_call_lua_cfunction NULL;
 
76
 
 
77
Section Public
 
78
 
 
79
  - create block:BLOCK :SELF <-
 
80
  (
 
81
    + other:SELF;
 
82
    other := clone;
 
83
    other.make block;
 
84
    other
 
85
  );
 
86
 
 
87
  - make block_:BLOCK <-
 
88
  (
 
89
    block := block_;
 
90
  );
 
91
 
 
92
  - get_pointer :POINTER <-
 
93
  (
 
94
    creator_of_lua_cfunctions;
 
95
    `lisaac_call_lua_cfunction0`:POINTER
 
96
  );
 
97
  /*(
 
98
    + block :BLOCK;
 
99
    block := Self.block;
 
100
    `(void*) @block`:POINTER
 
101
  );*/
 
102
 
 
103
// kate: hl Lisaac v0.2; indent-width 2; space-indent on; replace-tabs off;
 
104
// kate: tab-width 8; remove-trailing-space on;