(unknown charset) [BLACKBOX] Question about Meta.LookupPath

From: (unknown charset) unknown charset <no email>
Date: Thu, 11 Jul 2013 20:05:20 +0400

----boundary-LibPST-iamunique-634535219_-_-
Content-type: text/plain

Hi there.

Some time ago I started a small project, that included SQL routines via
SqlDB services.
Among other features, my project includes some interaction of SqlDB module
and global record variable field, that can be addressed by usage of symbol
":"
For example: SELECT * FROM divisions WHERE id = :PrivMod.rec.id

The point is that PrivMod.rec is ANYPTR that is dynamically initialized
during system work.
But I am always sure that if rec#NIL real object contains exported .id
field.

Unfortunatly, magic is broken :( because of strange limitation of
Meta.LookupPath procedure, used in SqlDB.Compile.

I've performed some tests and found than LookupPath cannot actually find
the "PrivMod.rec.id" if rec: ANYPTR, rec#NIL and rec(MyMod.MyType).id
exists.
Obviously, Meta mechanisms itself finds this field easily, trouble in the
LookupPath procedure.

I've prepared some demo fix:

Original:
> PROCEDURE LookupPath* (IN path: ARRAY OF CHAR; OUT i: Item);
> VAR j, n: INTEGER; name: Name; ch: CHAR; done: BOOLEAN; filter:
> FilterHook;
> BEGIN
> done := FALSE; filter := filterHook;
> WHILE ~done & (filter # NIL) DO filter.filter(path, i, done); filter :=
> filter.next END;
> IF ~done THEN
> j := 0;
> GetName(path, name, j);
> Lookup(name, i);
> IF (i.obj = modObj) & (path[j] = ".") THEN
> INC(j); GetName(path, name, j);
> i.Lookup(name, i); ch := path[j]; INC(j);
> WHILE (i.obj = varObj) & (ch # 0X) DO
> IF i.typ = ptrTyp THEN i.Deref(i) END;
> IF ch = "." THEN
> GetName(path, name, j);
> IF i.typ = recTyp THEN i.Lookup(name, i) ELSE SetUndef(i) END
> ELSIF ch = "[" THEN
> n := 0; ch := path[j]; INC(j);
> WHILE (ch >= "0") & (ch <= "9") DO n := 10 * n + ORD(ch) -
> ORD("0"); ch := path[j]; INC(j) END;
> IF (ch = "]") & (i.typ = arrTyp) THEN i.Index(n, i) ELSE
> SetUndef(i) END
> END;
> ch := path[j]; INC(j)
> END
> END
> END
> END LookupPath;

My fix:
> PROCEDURE LookupPath* (IN path: ARRAY OF CHAR; OUT i: Item);
> VAR j, n: INTEGER; name: Name; ch: CHAR; done: BOOLEAN; filter:
> FilterHook;
> BEGIN
> done := FALSE; filter := filterHook;
> WHILE ~done & (filter # NIL) DO filter.filter(path, i, done); filter :=
> filter.next END;
> IF ~done THEN
> j := 0;
> GetName(path, name, j);
> Lookup(name, i);
> IF (i.obj = modObj) & (path[j] = ".") THEN
> INC(j); GetName(path, name, j);
> i.Lookup(name, i); ch := path[j]; INC(j);
> WHILE (i.obj = varObj) & (ch # 0X) DO
> IF i.typ = ptrTyp THEN i.Deref(i) END;
> IF ch = "." THEN
> GetName(path, name, j);
> CASE i.typ OF
> recTyp: i.Lookup(name, i)
> |ptrTyp, anyPtrTyp: i.Deref(i);
> ASSERT(i.obj=varObj, 40);
> i.Lookup(name, i)
> ELSE SetUndef(i) END
> ELSIF ch = "[" THEN
> n := 0; ch := path[j]; INC(j);
> WHILE (ch >= "0") & (ch <= "9") DO n := 10 * n + ORD(ch) -
> ORD("0"); ch := path[j]; INC(j) END;
> IF (ch = "]") & (i.typ = arrTyp) THEN i.Index(n, i) ELSE
> SetUndef(i) END
> END;
> ch := path[j]; INC(j)
> END
> END
> END
> END LookupPath;

So, i wonder if someone knows what was the reason of such limitation and
is it possible to accumulate such fix in further versions of BB (rc7,
maybe :D )

Best regards.
-- 
Using Opera's revolutionary email client: http://www.opera.com/mail/
----
To unsubscribe, send a message with body "SIGNOFF BLACKBOX" to LISTSERV{([at]})nowhere.xy----boundary-LibPST-iamunique-634535219_-_-
Content-type: application/rtf
Content-transfer-encoding: base64
Content-Disposition: attachment; filename="rtf-body.rtf"
e1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZnJvbXRleHQgXGZiaWRpcyBcZGVmZjB7XGZvbnR0YmwN
CntcZjBcZnN3aXNzIEFyaWFsO30NCntcZjFcZm1vZGVybiBDb3VyaWVyIE5ldzt9DQp7XGYyXGZu
aWxcZmNoYXJ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ccGFyDQpVc2lu
ZyBPcGVyYSdzIHJldm9sdXRpb25hcnkgZW1haWwgY2xpZW50OiBodHRwOi8vd3d3Lm9wZXJhLmNv
bS9tYWlsL1xwYXINClxwYXINClxwYXINCi0tLS1ccGFyDQpUbyB1bnN1YnNjcmliZSwgc2VuZCBh
IG1lc3NhZ2Ugd2l0aCBib2R5ICJTSUdOT0ZGIEJMQUNLQk9YIiB0byBMSVNUU0VSVkBMSVNUUy5P
QkVST04uQ0hccGFyDQp9
----boundary-LibPST-iamunique-634535219_-_---
Received on Thu Jul 11 2013 - 18:05:20 UTC

This archive was generated by hypermail 2.3.0 : Thu Sep 26 2013 - 06:29:52 UTC