SquidDev, on 05 May 2014 - 02:19 PM, said:
Just one thing I found bug (or problem) I found when messing around with it: When you override the toString method, you have to return a String object, rather than the default Lua string. Otherwise you get an error. I think this is caused by see\bin\see (line 138): return value:toString():lstr(). I don't know if this is intentional but my 'fix' is:
local str = value:toString() if type(str) == "string" then return str end return str:lstr()
Otherwise this is such a great resource. Several things I would like to be seen in the future:
Proper event manager: This would be mainly for GUIs.Ignore me. I just read through your WeeGUI code and you already have that implimented but it would be nice to see this in the core SEE libary.- Sandboxing: I figure that if SEE has direct control over APIs then you could limit access to particular APIs. For instance ban access to websites or force a program to only run in one folder. This would be useful not only for untrusted code (not that there is much on CC) but also for debugging - you wouldn't be able to muck up the current file structure.
- Extensions to the current APIs: At the moment the SEE APIs (Rednet, Peripheral, etc...) simply replicate the built in APIs. It would be great if some new features could be added. This might include, for example, in the Rednet API one could make the side parameter for isOpen, open and close optional.
Glad you like it SquidDev!
toString should always return a see.base.String rather than a normal Lua string. It needs to do that because both user code and runtime code may call it. Since it can get called by user code directly, we don't want the user to have to worry about casting those strings. They should always be expecting a see.base.String. The line you're referencing is in see/apis/see, and it actually is for casting objects to normal strings.
About event handling, I'd like to keep the core event system pretty much the way it currently is. The main problem with listener style handling is that eventually you can get into callback hell with listeners inside listeners inside listeners (etc). That was actually the way I originally did the events system, using hooks (You can probably find them in some commits waaay back). The current events system works much better with the threading system, which by the way, you should totally play with that.
Of course, listener style event handling works pretty well for GUI systems because they're so object-oriented. That's why it has its own custom event system.
Now, sandboxing. I was thinking about doing that when someone was making that new browser that was supposed to be pretty awesome, but he ended up being our biggest critic so I didn't think too much more about it. Still though, SEE applets would be pretty damn cool for the new Firewolf I think. All you'd need to do is call the SEE API functions from Firewolf to load the runtime in. At that point, natives would have to be disabled and file APIs would need to be restricted. There could be something similar to Java like a SecurityManager or something to do the sandboxing. Maybe you get an instance of the SecurityManager and it tracks the level of the object. Code with access to higher level security managers would be able to sandbox potentially unsafe code by writing settings to the object. The same code would still be able to do as it pleases by temporarily disabling the manager when it needs to do some protected operations. Hmm, this might actually be a really neat idea.
SquidDev, on 07 May 2014 - 04:36 PM, said:
I was playing around with the SEE Rednet API and I don't think it works. I am aware of the ModemInputStream and ModemOutputStream APIs but they are not as effective as the original Rednet API as they don't provide all functionality. I know I could just pull RendetMessageEvent (but you warn us against it) or ModemMessageEvent but this still does not give me the ability to use functions such as lookup.
I think the only bit of Rednet that does not work is receiving (so rednet.receive and rednet.lookup). I think what happens is that the "rednet_message" event is never found (as it is gobbled up by the /apis/see and queued internally instead). As a result neither of these two functions return.
This 'event gobbling' bug also affects other core functionality such as read (and System.read).
Short of re-creating the entire Rednet API I can't find a decent solution.
Sorry to sound so negative, everything else works perfectly.
I may ask sci4me about some of those things because he added in the rednet stuff for the update to CC1.6. It's quite possible he ended up just wrapping the functions directly instead of pulling the correct event. This a problem I had with sleep a while back, and then realized that I'd just need to queue and pull timer events manually in the code rather than calling the native sleep since the events system works differently.
Edit: Yep, he's directly calling rednet.receive and rednet.lookup. Those functions will end up pulling events the native way and just break stuff.
Edited by Yevano, 07 May 2014 - 09:19 PM.











