| 
                Last change
                  on this file since 2172 was
                  2087,
                  checked in by landauf, 17 years ago
           | 
        
        
          | 
               
merged objecthierarchy branch back to trunk 
 
           | 
        
        
          
            
              - 
                  Property svn:eol-style set to
                  
native
               
             
           | 
        
        | 
            File size:
            1.3 KB
           | 
      
      
        
  | Rev | Line |   | 
|---|
| [1650] | 1 | -- tolua: define class | 
|---|
 | 2 | -- Written by Waldemar Celes | 
|---|
 | 3 | -- TeCGraf/PUC-Rio | 
|---|
 | 4 | -- Jul 1998 | 
|---|
 | 5 | -- $Id: define.lua,v 1.2 1999/07/28 22:21:08 celes Exp $ | 
|---|
 | 6 |  | 
|---|
 | 7 | -- This code is free software; you can redistribute it and/or modify it. | 
|---|
 | 8 | -- The software provided hereunder is on an "as is" basis, and | 
|---|
 | 9 | -- the author has no obligation to provide maintenance, support, updates, | 
|---|
 | 10 | -- enhancements, or modifications. | 
|---|
 | 11 |  | 
|---|
 | 12 |  | 
|---|
 | 13 | -- Define class | 
|---|
 | 14 | -- Represents a numeric const definition | 
|---|
 | 15 | -- The following filds are stored: | 
|---|
 | 16 | --   name = constant name | 
|---|
 | 17 | classDefine = { | 
|---|
 | 18 |  name = '', | 
|---|
 | 19 | } | 
|---|
 | 20 | classDefine.__index = classDefine | 
|---|
 | 21 | setmetatable(classDefine,classFeature) | 
|---|
 | 22 |  | 
|---|
 | 23 | -- register define | 
|---|
 | 24 | function classDefine:register (pre) | 
|---|
 | 25 |         if not self:check_public_access() then | 
|---|
 | 26 |                 return | 
|---|
 | 27 |         end | 
|---|
 | 28 |  | 
|---|
 | 29 |  pre = pre or '' | 
|---|
 | 30 |  output(pre..'tolua_constant(tolua_S,"'..self.lname..'",'..self.name..');') | 
|---|
 | 31 | end | 
|---|
 | 32 |  | 
|---|
 | 33 | -- Print method | 
|---|
 | 34 | function classDefine:print (ident,close) | 
|---|
 | 35 |  print(ident.."Define{") | 
|---|
 | 36 |  print(ident.." name = '"..self.name.."',") | 
|---|
 | 37 |  print(ident.." lname = '"..self.lname.."',") | 
|---|
 | 38 |  print(ident.."}"..close) | 
|---|
 | 39 | end | 
|---|
 | 40 |  | 
|---|
 | 41 |  | 
|---|
 | 42 | -- Internal constructor | 
|---|
 | 43 | function _Define (t) | 
|---|
 | 44 |  setmetatable(t,classDefine) | 
|---|
 | 45 |  t:buildnames() | 
|---|
 | 46 |  | 
|---|
 | 47 |  if t.name == '' then | 
|---|
 | 48 |   error("#invalid define") | 
|---|
 | 49 |  end | 
|---|
 | 50 |  | 
|---|
 | 51 |  append(t) | 
|---|
 | 52 |  return t | 
|---|
 | 53 | end | 
|---|
 | 54 |  | 
|---|
 | 55 | -- Constructor | 
|---|
 | 56 | -- Expects a string representing the constant name | 
|---|
 | 57 | function Define (n) | 
|---|
 | 58 |  return _Define{ | 
|---|
 | 59 |   name = n | 
|---|
 | 60 |  } | 
|---|
 | 61 | end | 
|---|
 | 62 |  | 
|---|
 | 63 |  | 
|---|
       
      
      Note: See 
TracBrowser
        for help on using the repository browser.