[Plugin] Function-like Namespaces

Post your completed addons to share with the community

Post » Sat Jan 04, 2014 11:59 pm

Namespaces

Namespaces are virtually identical to the core Function plugin. The only difference is that you can create more than one Namespace object. If you're using a lot of functions, you can break them up into multiple Namespace objects, helping organize your code and prevent name collisions.

You add, call, and inspect Namespace objects exactly like you would the vanilla Function object.

Namespaces are independent from one another calling a function from namespace A should never trigger a function in namespace B.


A Very Simple Demo

Downloads
namespace.c2addon
namespace_demo.capx

Some notes:
- This plugin is literally the core Function plugin with the singleton tag taken out and the some strings judiciously edited. All credit goes to the fine folk who developed the function plugin for creating such a robust piece of code.
- Unlike the Function plugin, namespaces aren't singletons. That means that it's technically possible to create and destroy namespace objects, among other things. I wouldn't particularly advise using those features, but, hey, I'm not your boss. The practical upshot is that the Namespace event windows are a bit more cluttered than the vanilla Function object.
B
6
S
1
Posts: 8
Reputation: 350

Post » Sun Jan 05, 2014 5:26 pm

IMPORTANT UPDATE (Edit: Problem resolved! See below)

After more testing, it appears that my plugin breaks when used with nested function calls. I'll update the original post accordingly.

I guess I now know why there was such a song and dance with the func stack.

Edit: Well, apparently I can't edit the OP because I don't have enough rep to post the hyperlinks that are already there?
ScottA2014-01-07 15:53:59
B
6
S
1
Posts: 8
Reputation: 350

Post » Tue Jan 07, 2014 5:06 pm

UPDATE 2 - Problem resolved!

Well, it turns out that the bug I thought I had was nothing but a red herring. I'm a bit embarrassed to say that I missed converting a function call to a namespace call in some code I was converting, and erroneously assumed that the plugin was at fault.

I now am quite sure that the plugin is working as intended!

I've nonetheless updated the plugin download link to an new version of the plugin. The major change of note is that individual namespace objects now maintain their own function stacks. This will probably prevent weird collisions with nested namespace calls.

I've also updated the demo to be much more extensive and easier to read. Be sure to clear your browser cache if you've looked at it before.ScottA2014-01-07 17:11:46
B
6
S
1
Posts: 8
Reputation: 350

Post » Sat Apr 05, 2014 4:15 pm

Made a minor update to this plugin

Changes in version 1.0.5
- Error messages now include the name of the namespace.
- Return value error messages include the value the action was trying to return

The demo has been updated to demonstrate the new error messages (in preview mode, of course)
B
6
S
1
Posts: 8
Reputation: 350


Return to Completed Addons

Who is online

Users browsing this forum: No registered users and 2 guests