Commits

Alex Ames committed df01e36 Draft

Backed out changeset: edd44e91af5f

  • Participants
  • Parent commits edd44e9

Comments (0)

Files changed (6)

 }
 
 
-LON_API lon_Object *lon_getfield(const lon_Object *o, const char *s) {
+LON_API const lon_Object *lon_getfield(const lon_Object *o, const char *s) {
   if (lon_istable(o)) {
     Table *h = hvalue(o);
     return lonH_getstr(h, s);
 }
 
 
-LON_API lon_Object *lon_getfieldi(const lon_Object *o, int i) {
+LON_API const lon_Object *lon_getfieldi(const lon_Object *o, int i) {
   if (lon_istable(o)) {
     Table *h = hvalue(o);
     return lonH_getnum(h, i);
 }
 
 
-LON_API lon_Object *lon_getfieldn(const lon_Object *o, lon_Number n) {
-  if (lon_istable(o)) {
-    Table *h = hvalue(o);
-    lon_Object key;
-    setnvalue(&key, n);
-    return lonH_get(h, &key);
-  }
-  else
-    return lonO_nilobject;
-}
-
-
 static void initstate(lon_State *L, lon_Options *opts) {
   L->errorJmp.status = 0;
   L->opts = opts;
 
 
 
-lon_Object lonO_nilobject_ = {{0}, LON_TNIL};
+const lon_Object lonO_nilobject_ = {{0}, LON_TNIL};
 
 
 int lonO_log2 (unsigned int x) {
 
 #define lonO_nilobject		(&lonO_nilobject_)
 
-LONI_DATA lon_Object lonO_nilobject_;
+LONI_DATA const lon_Object lonO_nilobject_;
 
 #define ceillog2(x)	(lonO_log2((x)-1) + 1)
 
 LON_API lon_Integer lon_optinteger(const lon_Object *o, lon_Integer d);
 LON_API const char *lon_optstring(const lon_Object *o, const char *d);
 
-LON_API lon_Object *lon_getfield(const lon_Object *o, const char *s);
-LON_API lon_Object *lon_getfieldi(const lon_Object *o, int i);
-LON_API lon_Object *lon_getfieldn(const lon_Object *o, lon_Number n);
+LON_API const lon_Object *lon_getfield(const lon_Object *o, const char *s);
+LON_API const lon_Object *lon_getfieldi(const lon_Object *o, int i);
+LON_API const lon_Object *lon_getfieldn(const lon_Object *o, lon_Number n);
 
 LON_API lon_Object *lon_newobject(lon_Options *opts);
 LON_API int lon_setnil(lon_Options *opts, lon_Object *o);
 /*
 ** search function for integers
 */
-lon_Object *lonH_getnum (Table *t, int key) {
+const lon_Object *lonH_getnum (Table *t, int key) {
   /* (1 <= key && key <= t->sizearray) */
   if (cast(unsigned int, key-1) < cast(unsigned int, t->sizearray))
     return &t->array[key-1];
 /*
 ** search function for strings
 */
-lon_Object *lonH_getstr (Table *t, const char *key) {
+const lon_Object *lonH_getstr (Table *t, const char *key) {
   Node *n = hashstr(t, key);
   do {  /* check whether `key' is somewhere in the chain */
     if (lon_isstring(gkey(n)) && strcmp(svalue(gkey(n)), key) == 0)
 /*
 ** search function for strings
 */
-lon_Object *lonH_gettstr (Table *t, TString *key) {
+const lon_Object *lonH_gettstr (Table *t, TString *key) {
   Node *n = hashtstr(t, key);
   do {  /* check whether `key' is somewhere in the chain */
     if (lon_isstring(gkey(n)) && rawtsvalue(gkey(n)) == key)
 /*
 ** main search function
 */
-lon_Object *lonH_get (Table *t, const lon_Object *key) {
+const lon_Object *lonH_get (Table *t, const lon_Object *key) {
   switch (lon_type(key)) {
     case LON_TNIL: return lonO_nilobject;
     case LON_TSTRING: return lonH_gettstr(t, rawtsvalue(key));
 #define key2tval(n)	(&(n)->i_key.tvk)
 
 
-LONI_FUNC lon_Object *lonH_getnum (Table *t, int key);
+LONI_FUNC const lon_Object *lonH_getnum (Table *t, int key);
 LONI_FUNC lon_Object *lonH_setnum (lon_State *L, Table *t, int key);
-LONI_FUNC lon_Object *lonH_getstr (Table *t, const char *key);
-LONI_FUNC lon_Object *lonH_gettstr (Table *t, TString *key);
+LONI_FUNC const lon_Object *lonH_getstr (Table *t, const char *key);
+LONI_FUNC const lon_Object *lonH_gettstr (Table *t, TString *key);
 LONI_FUNC lon_Object *lonH_settstr (lon_State *L, Table *t, TString *key);
-LONI_FUNC lon_Object *lonH_get (Table *t, const lon_Object *key);
+LONI_FUNC const lon_Object *lonH_get (Table *t, const lon_Object *key);
 LONI_FUNC lon_Object *lonH_set (lon_State *L, Table *t, const lon_Object *key);
 LONI_FUNC Table *lonH_new (lon_State *L, int narray, int lnhash);
 LONI_FUNC void lonH_resizearray (lon_State *L, Table *t, int nasize);