<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -12,6 +12,9 @@ __defineProperty__(&quot;global&quot;, this, true, true, true);
      * @return {Object} the module scope
      */
     this.__defineProperty__(&quot;require&quot;, function(moduleName) {
+        if (moduleName &amp;&amp; moduleName.__modulePath__)
+            moduleName = moduleName.__modulePath__;
+        
         return getRhinoEngine().loadModule(getRhinoContext(), moduleName, this);
     }, true, true, true);
 
@@ -23,6 +26,9 @@ __defineProperty__(&quot;global&quot;, this, true, true, true);
      *        module in the calling scope
      */
     this.__defineProperty__(&quot;import&quot;, function(moduleName, propertyName) {
+        if (moduleName &amp;&amp; moduleName.__modulePath__)
+            moduleName = moduleName.__modulePath__;
+        
         var module = this.require(moduleName);
         if (module.__export__) {
             propertyName = propertyName || moduleName;
@@ -44,6 +50,9 @@ __defineProperty__(&quot;global&quot;, this, true, true, true);
      * @param moduleName the module name such as 'core.object'
      */
     this.__defineProperty__(&quot;include&quot;, function(moduleName) {
+        if (moduleName &amp;&amp; moduleName.__modulePath__)
+            moduleName = moduleName.__modulePath__;
+        
         var module = this.require(moduleName);
         var exported = module.__export__;
         if (!exported) {
@@ -57,6 +66,48 @@ __defineProperty__(&quot;global&quot;, this, true, true, true);
     }, true, true, true);
 
     /**
+     * JSAdapter making module scopes available through a modules object
+     */
+    this.__defineProperty__(&quot;modules&quot;, new JSAdapter({
+        __get__ : function(name) {
+            var moduleLoader = function(name){
+                
+                if (this[name])
+                    return this[name];
+                else if (name == '__modulePath__')
+                    return arguments.callee.modulePath;
+                
+                var modulePath = arguments.callee.modulePath 
+                    ? arguments.callee.modulePath +'.'+ name 
+                    : name;
+                
+                var subModuleObj, tostring;
+                try {
+                    subModuleObj = require(modulePath);
+                    tostring = function(){
+                        return ''+ subModuleObj;
+                    };
+                }
+                catch(e){
+                    subModuleObj = {};
+                    tostring = function(){
+                        return '[JSAdapter modules.'+ modulePath +']';
+                    };
+                };
+                
+                moduleLoader.modulePath = modulePath;
+                subModuleObj.__get__ = moduleLoader;
+                
+                var adapter = new JSAdapter(subModuleObj);
+                adapter.toString = tostring;
+                return adapter;
+            };
+    
+            return moduleLoader(name);
+        }
+    }), true, true, true);
+    
+    /**
      * Define the properties to be exported.
      * @param name one or more names of exported properties
      */</diff>
      <filename>modules/global.js</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>7d13094ad344e56eae56c63fbd1fc43401f49aca</id>
    </parent>
  </parents>
  <author>
    <name>Chris Zumbrunn</name>
    <email>chris@zumbrunn.com</email>
  </author>
  <url>http://github.com/zumbrunn/helma-ng/commit/fbd310d856ee30b9706ede83c4e371fb74459678</url>
  <id>fbd310d856ee30b9706ede83c4e371fb74459678</id>
  <committed-date>2008-11-07T04:11:47-08:00</committed-date>
  <authored-date>2008-11-07T04:11:47-08:00</authored-date>
  <message>readded modules object, providing JSAdapter based access to module scopes and made require, import and include work optionally with such a modules JSAdapter object</message>
  <tree>cb2f87e643d658e6a459a68bf7c04e59cbbc8ee5</tree>
  <committer>
    <name>Chris Zumbrunn</name>
    <email>chris@zumbrunn.com</email>
  </committer>
</commit>
