diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1997-02-20 12:51:14 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1997-02-20 12:51:14 -0300 |
| commit | 6769f3481701a17d15d513c5b875999d38d81877 (patch) | |
| tree | aedeeba87f17a4633750f5d9fdd5d7d001326293 | |
| parent | 0b110f7922b2e5c066f3b10f50e4d1079ccd7f93 (diff) | |
| download | lua-6769f3481701a17d15d513c5b875999d38d81877.tar.gz lua-6769f3481701a17d15d513c5b875999d38d81877.tar.bz2 lua-6769f3481701a17d15d513c5b875999d38d81877.zip | |
lua_Type is private (preparation for tags)
| -rw-r--r-- | lua.h | 35 | ||||
| -rw-r--r-- | opcode.c | 45 | ||||
| -rw-r--r-- | opcode.h | 16 |
3 files changed, 53 insertions, 43 deletions
| @@ -2,7 +2,7 @@ | |||
| 2 | ** LUA - Linguagem para Usuarios de Aplicacao | 2 | ** LUA - Linguagem para Usuarios de Aplicacao |
| 3 | ** Grupo de Tecnologia em Computacao Grafica | 3 | ** Grupo de Tecnologia em Computacao Grafica |
| 4 | ** TeCGraf - PUC-Rio | 4 | ** TeCGraf - PUC-Rio |
| 5 | ** $Id: lua.h,v 3.32 1996/11/20 13:49:32 roberto Exp roberto $ | 5 | ** $Id: lua.h,v 3.33 1997/02/11 11:40:01 roberto Exp roberto $ |
| 6 | */ | 6 | */ |
| 7 | 7 | ||
| 8 | 8 | ||
| @@ -14,25 +14,6 @@ | |||
| 14 | #define LUA_AUTHORS "W. Celes, R. Ierusalimschy & L. H. de Figueiredo" | 14 | #define LUA_AUTHORS "W. Celes, R. Ierusalimschy & L. H. de Figueiredo" |
| 15 | 15 | ||
| 16 | 16 | ||
| 17 | /* Private Part */ | ||
| 18 | |||
| 19 | typedef enum | ||
| 20 | { | ||
| 21 | LUA_T_NIL = -1, | ||
| 22 | LUA_T_NUMBER = -2, | ||
| 23 | LUA_T_STRING = -3, | ||
| 24 | LUA_T_ARRAY = -4, | ||
| 25 | LUA_T_FUNCTION = -5, | ||
| 26 | LUA_T_CFUNCTION= -6, | ||
| 27 | LUA_T_MARK = -7, | ||
| 28 | LUA_T_CMARK = -8, | ||
| 29 | LUA_T_LINE = -9, | ||
| 30 | LUA_T_USERDATA = 0 | ||
| 31 | } lua_Type; | ||
| 32 | |||
| 33 | |||
| 34 | /* Public Part */ | ||
| 35 | |||
| 36 | #define LUA_NOOBJECT 0 | 17 | #define LUA_NOOBJECT 0 |
| 37 | 18 | ||
| 38 | typedef void (*lua_CFunction) (void); | 19 | typedef void (*lua_CFunction) (void); |
| @@ -52,10 +33,10 @@ void lua_endblock (void); | |||
| 52 | lua_Object lua_getparam (int number); | 33 | lua_Object lua_getparam (int number); |
| 53 | #define lua_getresult(_) lua_getparam(_) | 34 | #define lua_getresult(_) lua_getparam(_) |
| 54 | 35 | ||
| 55 | #define lua_isnil(_) (lua_type(_)==LUA_T_NIL) | 36 | int lua_isnil (lua_Object object); |
| 56 | #define lua_istable(_) (lua_type(_)==LUA_T_ARRAY) | 37 | int lua_istable (lua_Object object); |
| 57 | #define lua_isuserdata(_) (lua_type(_)>=LUA_T_USERDATA) | 38 | int lua_isuserdata (lua_Object object); |
| 58 | #define lua_iscfunction(_) (lua_type(_)==LUA_T_CFUNCTION) | 39 | int lua_iscfunction (lua_Object object); |
| 59 | int lua_isnumber (lua_Object object); | 40 | int lua_isnumber (lua_Object object); |
| 60 | int lua_isstring (lua_Object object); | 41 | int lua_isstring (lua_Object object); |
| 61 | int lua_isfunction (lua_Object object); | 42 | int lua_isfunction (lua_Object object); |
| @@ -65,7 +46,6 @@ char *lua_getstring (lua_Object object); | |||
| 65 | lua_CFunction lua_getcfunction (lua_Object object); | 46 | lua_CFunction lua_getcfunction (lua_Object object); |
| 66 | void *lua_getbinarydata (lua_Object object); | 47 | void *lua_getbinarydata (lua_Object object); |
| 67 | int lua_getbindatasize (lua_Object object); | 48 | int lua_getbindatasize (lua_Object object); |
| 68 | void *lua_getuserdata (lua_Object object); | ||
| 69 | 49 | ||
| 70 | void lua_pushnil (void); | 50 | void lua_pushnil (void); |
| 71 | void lua_pushnumber (float n); | 51 | void lua_pushnumber (float n); |
| @@ -98,11 +78,14 @@ lua_Object lua_createtable (void); | |||
| 98 | 78 | ||
| 99 | #define lua_register(n,f) (lua_pushcfunction(f), lua_storeglobal(n)) | 79 | #define lua_register(n,f) (lua_pushcfunction(f), lua_storeglobal(n)) |
| 100 | 80 | ||
| 101 | #define lua_pushuserdata(u) lua_pushusertag(u, LUA_T_USERDATA) | 81 | #define lua_pushuserdata(u) lua_pushusertag(u, 0) |
| 82 | |||
| 102 | 83 | ||
| 103 | 84 | ||
| 104 | /* for compatibility with old versions. Avoid using these macros */ | 85 | /* for compatibility with old versions. Avoid using these macros */ |
| 105 | 86 | ||
| 87 | #define lua_getuserdata(o) (*(void **)lua_getbinarydata(o)) | ||
| 88 | |||
| 106 | #define lua_lockobject(o) lua_refobject(o,1) | 89 | #define lua_lockobject(o) lua_refobject(o,1) |
| 107 | #define lua_lock() lua_ref(1) | 90 | #define lua_lock() lua_ref(1) |
| 108 | #define lua_getlocked lua_getref | 91 | #define lua_getlocked lua_getref |
| @@ -3,7 +3,7 @@ | |||
| 3 | ** TecCGraf - PUC-Rio | 3 | ** TecCGraf - PUC-Rio |
| 4 | */ | 4 | */ |
| 5 | 5 | ||
| 6 | char *rcs_opcode="$Id: opcode.c,v 3.79 1997/01/31 14:27:11 roberto Exp roberto $"; | 6 | char *rcs_opcode="$Id: opcode.c,v 3.80 1997/02/11 11:35:05 roberto Exp roberto $"; |
| 7 | 7 | ||
| 8 | #include <setjmp.h> | 8 | #include <setjmp.h> |
| 9 | #include <stdio.h> | 9 | #include <stdio.h> |
| @@ -671,20 +671,41 @@ lua_Object lua_getparam (int number) | |||
| 671 | return CLS_current.base-CLS_current.num+number; | 671 | return CLS_current.base-CLS_current.num+number; |
| 672 | } | 672 | } |
| 673 | 673 | ||
| 674 | int lua_isnumber (lua_Object object) | 674 | int lua_isnil (lua_Object o) |
| 675 | { | 675 | { |
| 676 | return (object != LUA_NOOBJECT) && (tonumber(Address(object)) == 0); | 676 | return (o!= LUA_NOOBJECT) && (tag(Address(o)) == LUA_T_NIL); |
| 677 | } | 677 | } |
| 678 | 678 | ||
| 679 | int lua_isstring (lua_Object object) | 679 | int lua_istable (lua_Object o) |
| 680 | { | 680 | { |
| 681 | int t = lua_type(object); | 681 | return (o!= LUA_NOOBJECT) && (tag(Address(o)) == LUA_T_ARRAY); |
| 682 | } | ||
| 683 | |||
| 684 | int lua_isuserdata (lua_Object o) | ||
| 685 | { | ||
| 686 | return (o!= LUA_NOOBJECT) && (tag(Address(o)) == LUA_T_USERDATA); | ||
| 687 | } | ||
| 688 | |||
| 689 | int lua_iscfunction (lua_Object o) | ||
| 690 | { | ||
| 691 | int t = lua_type(o); | ||
| 692 | return (t == LUA_T_CMARK) || (t == LUA_T_CFUNCTION); | ||
| 693 | } | ||
| 694 | |||
| 695 | int lua_isnumber (lua_Object o) | ||
| 696 | { | ||
| 697 | return (o!= LUA_NOOBJECT) && (tonumber(Address(o)) == 0); | ||
| 698 | } | ||
| 699 | |||
| 700 | int lua_isstring (lua_Object o) | ||
| 701 | { | ||
| 702 | int t = lua_type(o); | ||
| 682 | return (t == LUA_T_STRING) || (t == LUA_T_NUMBER); | 703 | return (t == LUA_T_STRING) || (t == LUA_T_NUMBER); |
| 683 | } | 704 | } |
| 684 | 705 | ||
| 685 | int lua_isfunction (lua_Object object) | 706 | int lua_isfunction (lua_Object o) |
| 686 | { | 707 | { |
| 687 | int t = lua_type(object); | 708 | int t = lua_type(o); |
| 688 | return (t == LUA_T_FUNCTION) || (t == LUA_T_CFUNCTION) || | 709 | return (t == LUA_T_FUNCTION) || (t == LUA_T_CFUNCTION) || |
| 689 | (t == LUA_T_MARK) || (t == LUA_T_CMARK); | 710 | (t == LUA_T_MARK) || (t == LUA_T_CMARK); |
| 690 | } | 711 | } |
| @@ -734,14 +755,6 @@ lua_CFunction lua_getcfunction (lua_Object object) | |||
| 734 | else return (fvalue(Address(object))); | 755 | else return (fvalue(Address(object))); |
| 735 | } | 756 | } |
| 736 | 757 | ||
| 737 | /* | ||
| 738 | ** Given an object handle, return its user data. On error, return NULL. | ||
| 739 | */ | ||
| 740 | void *lua_getuserdata (lua_Object object) | ||
| 741 | { | ||
| 742 | return *(void **)lua_getbinarydata(object); | ||
| 743 | } | ||
| 744 | |||
| 745 | 758 | ||
| 746 | lua_Object lua_getref (int ref) | 759 | lua_Object lua_getref (int ref) |
| 747 | { | 760 | { |
| @@ -888,7 +901,7 @@ int lua_type (lua_Object o) | |||
| 888 | lua_Type t = tag(Address(o)); | 901 | lua_Type t = tag(Address(o)); |
| 889 | if (t == LUA_T_USERDATA) | 902 | if (t == LUA_T_USERDATA) |
| 890 | return (Address(o))->value.ts->tag; | 903 | return (Address(o))->value.ts->tag; |
| 891 | else return tag(Address(o)); | 904 | else return t; |
| 892 | } | 905 | } |
| 893 | } | 906 | } |
| 894 | 907 | ||
| @@ -1,6 +1,6 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** TeCGraf - PUC-Rio | 2 | ** TeCGraf - PUC-Rio |
| 3 | ** $Id: opcode.h,v 3.24 1996/11/01 12:46:59 roberto Exp roberto $ | 3 | ** $Id: opcode.h,v 3.25 1997/02/11 11:35:05 roberto Exp roberto $ |
| 4 | */ | 4 | */ |
| 5 | 5 | ||
| 6 | #ifndef opcode_h | 6 | #ifndef opcode_h |
| @@ -14,6 +14,20 @@ | |||
| 14 | 14 | ||
| 15 | #define FIELDS_PER_FLUSH 40 | 15 | #define FIELDS_PER_FLUSH 40 |
| 16 | 16 | ||
| 17 | typedef enum | ||
| 18 | { | ||
| 19 | LUA_T_NIL = -1, | ||
| 20 | LUA_T_NUMBER = -2, | ||
| 21 | LUA_T_STRING = -3, | ||
| 22 | LUA_T_ARRAY = -4, /* array==table */ | ||
| 23 | LUA_T_FUNCTION = -5, | ||
| 24 | LUA_T_CFUNCTION= -6, | ||
| 25 | LUA_T_MARK = -7, | ||
| 26 | LUA_T_CMARK = -8, | ||
| 27 | LUA_T_LINE = -9, | ||
| 28 | LUA_T_USERDATA = 0 | ||
| 29 | } lua_Type; | ||
| 30 | |||
| 17 | 31 | ||
| 18 | typedef enum { | 32 | typedef enum { |
| 19 | /* name parm before after side effect | 33 | /* name parm before after side effect |
