jruby-win32ole 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +7 -0
 - data/Gemfile +4 -0
 - data/README +0 -0
 - data/Rakefile +8 -0
 - data/VERSION +1 -0
 - data/bin/make_data.rb +12 -0
 - data/bin/sample +11 -0
 - data/build.xml +74 -0
 - data/jruby-win32ole.gemspec +21 -0
 - data/lib/jruby-win32ole.rb +39 -0
 - data/lib/jruby-win32ole/version.rb +5 -0
 - data/lib/racob-x64.dll +0 -0
 - data/lib/racob-x86.dll +0 -0
 - data/lib/racob.jar +0 -0
 - data/lib/win32ole/utils.rb +230 -0
 - data/lib/win32ole/win32ole.jar +0 -0
 - data/lib/win32ole/win32ole_error.rb +13 -0
 - data/lib/win32ole/win32ole_event.rb +38 -0
 - data/lib/win32ole/win32ole_method.rb +135 -0
 - data/lib/win32ole/win32ole_param.rb +45 -0
 - data/lib/win32ole/win32ole_ruby.rb +115 -0
 - data/lib/win32ole/win32ole_type.rb +148 -0
 - data/lib/win32ole/win32ole_typelib.rb +76 -0
 - data/lib/win32ole/win32ole_variable.rb +41 -0
 - data/lib/win32ole/win32ole_variant.rb +52 -0
 - data/nbproject/build-impl.xml +800 -0
 - data/nbproject/genfiles.properties +8 -0
 - data/nbproject/private/config.properties +0 -0
 - data/nbproject/private/private.properties +8 -0
 - data/nbproject/private/private.xml +4 -0
 - data/nbproject/project.properties +71 -0
 - data/nbproject/project.xml +14 -0
 - data/samples/browser_connect.rb +10 -0
 - data/samples/const_load.rb +10 -0
 - data/samples/dir_enum_bench.rb +24 -0
 - data/samples/dispatch_bench.rb +44 -0
 - data/samples/file_system_object.rb +7 -0
 - data/samples/fs.rb +50 -0
 - data/samples/ie_plus_events.rb +45 -0
 - data/samples/ie_simple.rb +20 -0
 - data/samples/ie_simple_clsid.rb +13 -0
 - data/samples/sbem.rb +11 -0
 - data/samples/small_enum_bench.rb +126 -0
 - data/src/org/jruby/ext/win32ole/RubyInvocationProxy.java +34 -0
 - data/src/org/jruby/ext/win32ole/RubyWIN32OLE.java +278 -0
 - data/src/win32ole/Win32oleService.java +29 -0
 - metadata +113 -0
 
| 
         @@ -0,0 +1,34 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            package org.jruby.ext.win32ole;
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            import org.racob.com.InvocationProxy;
         
     | 
| 
      
 4 
     | 
    
         
            +
            import org.racob.com.Variant;
         
     | 
| 
      
 5 
     | 
    
         
            +
            import org.jruby.Ruby;
         
     | 
| 
      
 6 
     | 
    
         
            +
            import org.jruby.runtime.ThreadContext;
         
     | 
| 
      
 7 
     | 
    
         
            +
            import org.jruby.runtime.builtin.IRubyObject;
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            /**
         
     | 
| 
      
 10 
     | 
    
         
            +
             */
         
     | 
| 
      
 11 
     | 
    
         
            +
            public class RubyInvocationProxy extends InvocationProxy {
         
     | 
| 
      
 12 
     | 
    
         
            +
                private final Ruby runtime;
         
     | 
| 
      
 13 
     | 
    
         
            +
                private final IRubyObject target;
         
     | 
| 
      
 14 
     | 
    
         
            +
                
         
     | 
| 
      
 15 
     | 
    
         
            +
                public RubyInvocationProxy(IRubyObject target) {
         
     | 
| 
      
 16 
     | 
    
         
            +
                    this.target = target;
         
     | 
| 
      
 17 
     | 
    
         
            +
                    this.runtime = target.getRuntime();
         
     | 
| 
      
 18 
     | 
    
         
            +
                }
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
                @Override
         
     | 
| 
      
 21 
     | 
    
         
            +
                public Variant invoke(String methodName, Variant[] variantArgs) {
         
     | 
| 
      
 22 
     | 
    
         
            +
                    ThreadContext context = runtime.getCurrentContext();
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
                    int length = variantArgs.length;
         
     | 
| 
      
 25 
     | 
    
         
            +
                    IRubyObject[] args = new IRubyObject[length];
         
     | 
| 
      
 26 
     | 
    
         
            +
                    for (int i = 0; i < length; i++) {
         
     | 
| 
      
 27 
     | 
    
         
            +
                        args[i] = RubyWIN32OLE.fromVariant(runtime, variantArgs[i]);
         
     | 
| 
      
 28 
     | 
    
         
            +
                    }
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
                    target.callMethod(context, methodName, args);
         
     | 
| 
      
 31 
     | 
    
         
            +
                    return null;
         
     | 
| 
      
 32 
     | 
    
         
            +
                }
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
            }
         
     | 
| 
         @@ -0,0 +1,278 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            package org.jruby.ext.win32ole;
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            import org.racob.com.Dispatch;
         
     | 
| 
      
 4 
     | 
    
         
            +
            import org.racob.com.EnumVariant;
         
     | 
| 
      
 5 
     | 
    
         
            +
            import org.racob.com.Variant;
         
     | 
| 
      
 6 
     | 
    
         
            +
            import java.util.Calendar;
         
     | 
| 
      
 7 
     | 
    
         
            +
            import java.util.Date;
         
     | 
| 
      
 8 
     | 
    
         
            +
            import org.jruby.Ruby;
         
     | 
| 
      
 9 
     | 
    
         
            +
            import org.jruby.RubyArray;
         
     | 
| 
      
 10 
     | 
    
         
            +
            import org.jruby.RubyClass;
         
     | 
| 
      
 11 
     | 
    
         
            +
            import org.jruby.RubyInteger;
         
     | 
| 
      
 12 
     | 
    
         
            +
            import org.jruby.RubyObject;
         
     | 
| 
      
 13 
     | 
    
         
            +
            import org.jruby.anno.JRubyMethod;
         
     | 
| 
      
 14 
     | 
    
         
            +
            import org.jruby.javasupport.JavaUtil;
         
     | 
| 
      
 15 
     | 
    
         
            +
            import org.jruby.runtime.Block;
         
     | 
| 
      
 16 
     | 
    
         
            +
            import org.jruby.runtime.ObjectAllocator;
         
     | 
| 
      
 17 
     | 
    
         
            +
            import org.jruby.runtime.ThreadContext;
         
     | 
| 
      
 18 
     | 
    
         
            +
            import org.jruby.runtime.builtin.IRubyObject;
         
     | 
| 
      
 19 
     | 
    
         
            +
            import win32ole.Win32oleService;
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
            /**
         
     | 
| 
      
 22 
     | 
    
         
            +
             */
         
     | 
| 
      
 23 
     | 
    
         
            +
            public class RubyWIN32OLE extends RubyObject {
         
     | 
| 
      
 24 
     | 
    
         
            +
                private static final Object[] EMPTY_OBJECT_ARGS = new Object[0];
         
     | 
| 
      
 25 
     | 
    
         
            +
                private static final int[] EMPTY_ERROR_ARGS = new int[0];
         
     | 
| 
      
 26 
     | 
    
         
            +
                
         
     | 
| 
      
 27 
     | 
    
         
            +
                public static ObjectAllocator WIN32OLE_ALLOCATOR = new ObjectAllocator() {
         
     | 
| 
      
 28 
     | 
    
         
            +
                    public IRubyObject allocate(Ruby runtime, RubyClass klass) {
         
     | 
| 
      
 29 
     | 
    
         
            +
                        return new RubyWIN32OLE(runtime, klass);
         
     | 
| 
      
 30 
     | 
    
         
            +
                    }
         
     | 
| 
      
 31 
     | 
    
         
            +
                };
         
     | 
| 
      
 32 
     | 
    
         
            +
                
         
     | 
| 
      
 33 
     | 
    
         
            +
                public Dispatch dispatch = null;
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
                public RubyWIN32OLE(Ruby runtime, RubyClass metaClass) {
         
     | 
| 
      
 36 
     | 
    
         
            +
                    super(runtime, metaClass);
         
     | 
| 
      
 37 
     | 
    
         
            +
                }
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
                private RubyWIN32OLE(Ruby runtime, RubyClass metaClass, Dispatch dispatch) {
         
     | 
| 
      
 40 
     | 
    
         
            +
                    this(runtime, metaClass);
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
                    this.dispatch = dispatch;
         
     | 
| 
      
 43 
     | 
    
         
            +
                }
         
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
      
 45 
     | 
    
         
            +
                public Dispatch getDispatch() {
         
     | 
| 
      
 46 
     | 
    
         
            +
                    return dispatch;
         
     | 
| 
      
 47 
     | 
    
         
            +
                }
         
     | 
| 
      
 48 
     | 
    
         
            +
             
     | 
| 
      
 49 
     | 
    
         
            +
                // Accessor for Ruby side of win32ole to get ahold of this object
         
     | 
| 
      
 50 
     | 
    
         
            +
                @JRubyMethod()
         
     | 
| 
      
 51 
     | 
    
         
            +
                public IRubyObject dispatch(ThreadContext context) {
         
     | 
| 
      
 52 
     | 
    
         
            +
                    return JavaUtil.convertJavaToUsableRubyObject(context.getRuntime(), dispatch);
         
     | 
| 
      
 53 
     | 
    
         
            +
                }
         
     | 
| 
      
 54 
     | 
    
         
            +
             
     | 
| 
      
 55 
     | 
    
         
            +
                @JRubyMethod()
         
     | 
| 
      
 56 
     | 
    
         
            +
                public IRubyObject each(ThreadContext context, Block block) {
         
     | 
| 
      
 57 
     | 
    
         
            +
                    Ruby runtime = context.getRuntime();
         
     | 
| 
      
 58 
     | 
    
         
            +
                    EnumVariant enumVariant = dispatch.toEnumVariant();
         
     | 
| 
      
 59 
     | 
    
         
            +
             
     | 
| 
      
 60 
     | 
    
         
            +
                    // FIXME: when no block is passed handling
         
     | 
| 
      
 61 
     | 
    
         
            +
                    
         
     | 
| 
      
 62 
     | 
    
         
            +
                    while (enumVariant.hasMoreElements()) {
         
     | 
| 
      
 63 
     | 
    
         
            +
                        Variant value = enumVariant.nextElement();
         
     | 
| 
      
 64 
     | 
    
         
            +
                        block.yield(context, fromVariant(runtime, value));
         
     | 
| 
      
 65 
     | 
    
         
            +
                    }
         
     | 
| 
      
 66 
     | 
    
         
            +
             
     | 
| 
      
 67 
     | 
    
         
            +
                    return runtime.getNil();
         
     | 
| 
      
 68 
     | 
    
         
            +
                }
         
     | 
| 
      
 69 
     | 
    
         
            +
             
     | 
| 
      
 70 
     | 
    
         
            +
                @JRubyMethod(required = 3)
         
     | 
| 
      
 71 
     | 
    
         
            +
                public IRubyObject _getproperty(ThreadContext context, IRubyObject dispid,
         
     | 
| 
      
 72 
     | 
    
         
            +
                        IRubyObject args, IRubyObject argTypes) {
         
     | 
| 
      
 73 
     | 
    
         
            +
                    RubyArray argsArray = args.convertToArray();
         
     | 
| 
      
 74 
     | 
    
         
            +
                    Object[] objectArgs = makeObjectArgs(argsArray);
         
     | 
| 
      
 75 
     | 
    
         
            +
                    int dispatchId = (int) RubyInteger.num2long(dispid);
         
     | 
| 
      
 76 
     | 
    
         
            +
                    
         
     | 
| 
      
 77 
     | 
    
         
            +
                    if (objectArgs.length == 0) {
         
     | 
| 
      
 78 
     | 
    
         
            +
                        return fromObject(context.getRuntime(), Dispatch.callO(dispatch, dispatchId));
         
     | 
| 
      
 79 
     | 
    
         
            +
                    } 
         
     | 
| 
      
 80 
     | 
    
         
            +
             
     | 
| 
      
 81 
     | 
    
         
            +
                    return fromVariant(context.getRuntime(),
         
     | 
| 
      
 82 
     | 
    
         
            +
                            Dispatch.call(dispatch, dispatchId, objectArgs));
         
     | 
| 
      
 83 
     | 
    
         
            +
                }
         
     | 
| 
      
 84 
     | 
    
         
            +
             
     | 
| 
      
 85 
     | 
    
         
            +
                @JRubyMethod(required = 1, rest = true)
         
     | 
| 
      
 86 
     | 
    
         
            +
                public IRubyObject initialize(ThreadContext context, IRubyObject[] args) {
         
     | 
| 
      
 87 
     | 
    
         
            +
                    String id = args[0].convertToString().asJavaString();
         
     | 
| 
      
 88 
     | 
    
         
            +
             
     | 
| 
      
 89 
     | 
    
         
            +
                    dispatch = new Dispatch(toProgID(id));
         
     | 
| 
      
 90 
     | 
    
         
            +
             
     | 
| 
      
 91 
     | 
    
         
            +
                    return this;
         
     | 
| 
      
 92 
     | 
    
         
            +
                }
         
     | 
| 
      
 93 
     | 
    
         
            +
             
     | 
| 
      
 94 
     | 
    
         
            +
                @JRubyMethod(required = 1, rest = true)
         
     | 
| 
      
 95 
     | 
    
         
            +
                public IRubyObject invoke(ThreadContext context, IRubyObject[] args) {
         
     | 
| 
      
 96 
     | 
    
         
            +
                    return method_missing(context, args);
         
     | 
| 
      
 97 
     | 
    
         
            +
                }
         
     | 
| 
      
 98 
     | 
    
         
            +
                
         
     | 
| 
      
 99 
     | 
    
         
            +
                @JRubyMethod()
         
     | 
| 
      
 100 
     | 
    
         
            +
                public IRubyObject _invoke(ThreadContext context, IRubyObject dispid,
         
     | 
| 
      
 101 
     | 
    
         
            +
                        IRubyObject args, IRubyObject typesArray) {
         
     | 
| 
      
 102 
     | 
    
         
            +
                    return invokeInternal(context, dispid, args, args, Dispatch.Method);
         
     | 
| 
      
 103 
     | 
    
         
            +
                }
         
     | 
| 
      
 104 
     | 
    
         
            +
             
     | 
| 
      
 105 
     | 
    
         
            +
                @JRubyMethod(required = 1, rest = true)
         
     | 
| 
      
 106 
     | 
    
         
            +
                public IRubyObject method_missing(ThreadContext context, IRubyObject[] args) {
         
     | 
| 
      
 107 
     | 
    
         
            +
                    String methodName = args[0].asJavaString();
         
     | 
| 
      
 108 
     | 
    
         
            +
                    
         
     | 
| 
      
 109 
     | 
    
         
            +
                    if (methodName.endsWith("=")) return invokeSet(context, 
         
     | 
| 
      
 110 
     | 
    
         
            +
                            methodName.substring(0, methodName.length() - 1), args);
         
     | 
| 
      
 111 
     | 
    
         
            +
             
     | 
| 
      
 112 
     | 
    
         
            +
                    return invokeMethodOrGet(context, methodName, args);
         
     | 
| 
      
 113 
     | 
    
         
            +
                }
         
     | 
| 
      
 114 
     | 
    
         
            +
             
     | 
| 
      
 115 
     | 
    
         
            +
                @JRubyMethod()
         
     | 
| 
      
 116 
     | 
    
         
            +
                public IRubyObject ole_free(ThreadContext context) {
         
     | 
| 
      
 117 
     | 
    
         
            +
                    dispatch.safeRelease();
         
     | 
| 
      
 118 
     | 
    
         
            +
             
     | 
| 
      
 119 
     | 
    
         
            +
                    return context.getRuntime().getNil();
         
     | 
| 
      
 120 
     | 
    
         
            +
                }
         
     | 
| 
      
 121 
     | 
    
         
            +
             
     | 
| 
      
 122 
     | 
    
         
            +
                @JRubyMethod(name = "[]", required = 1)
         
     | 
| 
      
 123 
     | 
    
         
            +
                public IRubyObject op_aref(ThreadContext context, IRubyObject property) {
         
     | 
| 
      
 124 
     | 
    
         
            +
                    String propertyName = property.asJavaString();
         
     | 
| 
      
 125 
     | 
    
         
            +
                    
         
     | 
| 
      
 126 
     | 
    
         
            +
                    return fromVariant(context.getRuntime(), Dispatch.get(dispatch, propertyName));
         
     | 
| 
      
 127 
     | 
    
         
            +
                }
         
     | 
| 
      
 128 
     | 
    
         
            +
             
     | 
| 
      
 129 
     | 
    
         
            +
                @JRubyMethod(name = "[]=", required = 2)
         
     | 
| 
      
 130 
     | 
    
         
            +
                public IRubyObject op_aset(ThreadContext context, IRubyObject property, IRubyObject value) {
         
     | 
| 
      
 131 
     | 
    
         
            +
                    String propertyName = property.asJavaString();
         
     | 
| 
      
 132 
     | 
    
         
            +
             
     | 
| 
      
 133 
     | 
    
         
            +
                    Dispatch.put(dispatch, propertyName, toObject(value));
         
     | 
| 
      
 134 
     | 
    
         
            +
                    return context.getRuntime().getNil();
         
     | 
| 
      
 135 
     | 
    
         
            +
                }
         
     | 
| 
      
 136 
     | 
    
         
            +
             
     | 
| 
      
 137 
     | 
    
         
            +
                @JRubyMethod()
         
     | 
| 
      
 138 
     | 
    
         
            +
                public IRubyObject _setproperty(ThreadContext context, IRubyObject dispid,
         
     | 
| 
      
 139 
     | 
    
         
            +
                        IRubyObject args, IRubyObject argTypes) {
         
     | 
| 
      
 140 
     | 
    
         
            +
                    return invokeInternal(context, dispid, args, argTypes, Dispatch.Put);
         
     | 
| 
      
 141 
     | 
    
         
            +
                }
         
     | 
| 
      
 142 
     | 
    
         
            +
             
     | 
| 
      
 143 
     | 
    
         
            +
                @JRubyMethod(required = 1, rest = true)
         
     | 
| 
      
 144 
     | 
    
         
            +
                public IRubyObject setproperty(ThreadContext context, IRubyObject[] args) {
         
     | 
| 
      
 145 
     | 
    
         
            +
                    String methodName = args[0].asJavaString();
         
     | 
| 
      
 146 
     | 
    
         
            +
                    
         
     | 
| 
      
 147 
     | 
    
         
            +
                    return invokeSet(context, methodName, args);
         
     | 
| 
      
 148 
     | 
    
         
            +
                }
         
     | 
| 
      
 149 
     | 
    
         
            +
             
     | 
| 
      
 150 
     | 
    
         
            +
                private IRubyObject invokeSet(ThreadContext context, String methodName, IRubyObject[] args) {
         
     | 
| 
      
 151 
     | 
    
         
            +
                    Object[] objectArgs = makeObjectArgs(args, 1);
         
     | 
| 
      
 152 
     | 
    
         
            +
                    int[] errorArgs = new int[objectArgs.length];
         
     | 
| 
      
 153 
     | 
    
         
            +
             
     | 
| 
      
 154 
     | 
    
         
            +
                    Dispatch.invoke(dispatch, methodName, Dispatch.Put, objectArgs, errorArgs);
         
     | 
| 
      
 155 
     | 
    
         
            +
                    return context.getRuntime().getNil();
         
     | 
| 
      
 156 
     | 
    
         
            +
                }
         
     | 
| 
      
 157 
     | 
    
         
            +
             
     | 
| 
      
 158 
     | 
    
         
            +
                private IRubyObject invokeInternal(ThreadContext context, IRubyObject dispid,
         
     | 
| 
      
 159 
     | 
    
         
            +
                        IRubyObject args, IRubyObject argTypes, int dispatchType) {
         
     | 
| 
      
 160 
     | 
    
         
            +
                    RubyArray argsArray = args.convertToArray();
         
     | 
| 
      
 161 
     | 
    
         
            +
                    int dispatchId = (int) RubyInteger.num2long(dispid);
         
     | 
| 
      
 162 
     | 
    
         
            +
                    Object[] objectArgs = makeObjectArgs(argsArray);
         
     | 
| 
      
 163 
     | 
    
         
            +
                    int[] errorArgs = makeErrorArgs(objectArgs.length);
         
     | 
| 
      
 164 
     | 
    
         
            +
                    Variant returnValue = Dispatch.invoke(dispatch, dispatchId, dispatchType,
         
     | 
| 
      
 165 
     | 
    
         
            +
                            objectArgs, errorArgs);
         
     | 
| 
      
 166 
     | 
    
         
            +
             
     | 
| 
      
 167 
     | 
    
         
            +
                    return fromVariant(context.getRuntime(), returnValue);
         
     | 
| 
      
 168 
     | 
    
         
            +
                }
         
     | 
| 
      
 169 
     | 
    
         
            +
                private int[] makeErrorArgs(int size) {
         
     | 
| 
      
 170 
     | 
    
         
            +
                    return size <= 0 ? EMPTY_ERROR_ARGS : new int[size];
         
     | 
| 
      
 171 
     | 
    
         
            +
                }
         
     | 
| 
      
 172 
     | 
    
         
            +
             
     | 
| 
      
 173 
     | 
    
         
            +
                private Object[] makeObjectArgs(IRubyObject[] rubyArgs, int startIndex) {
         
     | 
| 
      
 174 
     | 
    
         
            +
                    int length = rubyArgs.length;
         
     | 
| 
      
 175 
     | 
    
         
            +
                    if (length - startIndex <= 0) return EMPTY_OBJECT_ARGS;
         
     | 
| 
      
 176 
     | 
    
         
            +
             
     | 
| 
      
 177 
     | 
    
         
            +
                    Object[] objectArgs = new Object[length - startIndex];
         
     | 
| 
      
 178 
     | 
    
         
            +
                    for (int i = startIndex; i < length; i++) {
         
     | 
| 
      
 179 
     | 
    
         
            +
                        objectArgs[i - startIndex] = RubyWIN32OLE.toObject(rubyArgs[i]);
         
     | 
| 
      
 180 
     | 
    
         
            +
                    }
         
     | 
| 
      
 181 
     | 
    
         
            +
             
     | 
| 
      
 182 
     | 
    
         
            +
                    return objectArgs;
         
     | 
| 
      
 183 
     | 
    
         
            +
                }
         
     | 
| 
      
 184 
     | 
    
         
            +
             
     | 
| 
      
 185 
     | 
    
         
            +
                private Object[] makeObjectArgs(RubyArray argsArray) {
         
     | 
| 
      
 186 
     | 
    
         
            +
                    int length = argsArray.size();
         
     | 
| 
      
 187 
     | 
    
         
            +
                    if (length <= 0) return EMPTY_OBJECT_ARGS;
         
     | 
| 
      
 188 
     | 
    
         
            +
             
     | 
| 
      
 189 
     | 
    
         
            +
                    Object[] objectArgs = new Object[length];
         
     | 
| 
      
 190 
     | 
    
         
            +
                    for (int i = 0; i < length; i++) {
         
     | 
| 
      
 191 
     | 
    
         
            +
                        Object object = toObject(argsArray.eltInternal(i));
         
     | 
| 
      
 192 
     | 
    
         
            +
                        objectArgs[i] = object;
         
     | 
| 
      
 193 
     | 
    
         
            +
                    }
         
     | 
| 
      
 194 
     | 
    
         
            +
             
     | 
| 
      
 195 
     | 
    
         
            +
                    return objectArgs;
         
     | 
| 
      
 196 
     | 
    
         
            +
                }
         
     | 
| 
      
 197 
     | 
    
         
            +
             
     | 
| 
      
 198 
     | 
    
         
            +
                private IRubyObject invokeMethodOrGet(ThreadContext context, String methodName, IRubyObject[] args) {
         
     | 
| 
      
 199 
     | 
    
         
            +
                    if (args.length == 1) { // No-arg call
         
     | 
| 
      
 200 
     | 
    
         
            +
                        return fromObject(context.getRuntime(), Dispatch.callO(dispatch, methodName));
         
     | 
| 
      
 201 
     | 
    
         
            +
                    } 
         
     | 
| 
      
 202 
     | 
    
         
            +
                    return fromVariant(context.getRuntime(),
         
     | 
| 
      
 203 
     | 
    
         
            +
                            Dispatch.callN(dispatch, methodName, makeObjectArgs(args, 1)));
         
     | 
| 
      
 204 
     | 
    
         
            +
                }
         
     | 
| 
      
 205 
     | 
    
         
            +
             
     | 
| 
      
 206 
     | 
    
         
            +
                @Override
         
     | 
| 
      
 207 
     | 
    
         
            +
                public Object toJava(Class klass) {
         
     | 
| 
      
 208 
     | 
    
         
            +
                    return dispatch;
         
     | 
| 
      
 209 
     | 
    
         
            +
                }
         
     | 
| 
      
 210 
     | 
    
         
            +
             
     | 
| 
      
 211 
     | 
    
         
            +
                public static Object toObject(IRubyObject rubyObject) {
         
     | 
| 
      
 212 
     | 
    
         
            +
                    return rubyObject.toJava(Object.class);
         
     | 
| 
      
 213 
     | 
    
         
            +
                }
         
     | 
| 
      
 214 
     | 
    
         
            +
             
     | 
| 
      
 215 
     | 
    
         
            +
                public static IRubyObject fromObject(Ruby runtime, Object object) {
         
     | 
| 
      
 216 
     | 
    
         
            +
                    if (object == null) return runtime.getNil();
         
     | 
| 
      
 217 
     | 
    
         
            +
             
     | 
| 
      
 218 
     | 
    
         
            +
                    if (object instanceof Boolean) {
         
     | 
| 
      
 219 
     | 
    
         
            +
                        return runtime.newBoolean(((Boolean) object).booleanValue());
         
     | 
| 
      
 220 
     | 
    
         
            +
                    } else if (object instanceof Dispatch) {
         
     | 
| 
      
 221 
     | 
    
         
            +
                        return new RubyWIN32OLE(runtime, Win32oleService.getMetaClass(), (Dispatch) object);
         
     | 
| 
      
 222 
     | 
    
         
            +
                    } else if (object instanceof Date) {
         
     | 
| 
      
 223 
     | 
    
         
            +
                        return date2ruby(runtime, (Date) object);
         
     | 
| 
      
 224 
     | 
    
         
            +
                    } else if (object instanceof Number) {
         
     | 
| 
      
 225 
     | 
    
         
            +
                        if (object instanceof Double) {
         
     | 
| 
      
 226 
     | 
    
         
            +
                            return runtime.newFloat(((Double) object).doubleValue());
         
     | 
| 
      
 227 
     | 
    
         
            +
                        } else if (object instanceof Float) {
         
     | 
| 
      
 228 
     | 
    
         
            +
                            return runtime.newFloat(((Float) object).doubleValue());
         
     | 
| 
      
 229 
     | 
    
         
            +
                        }
         
     | 
| 
      
 230 
     | 
    
         
            +
             
     | 
| 
      
 231 
     | 
    
         
            +
                        return runtime.newFixnum(((Number) object).intValue());
         
     | 
| 
      
 232 
     | 
    
         
            +
                    } else if (object instanceof String) {
         
     | 
| 
      
 233 
     | 
    
         
            +
                        return runtime.newString((String) object);
         
     | 
| 
      
 234 
     | 
    
         
            +
                    }
         
     | 
| 
      
 235 
     | 
    
         
            +
             
     | 
| 
      
 236 
     | 
    
         
            +
                    return JavaUtil.convertJavaToUsableRubyObject(runtime, object);
         
     | 
| 
      
 237 
     | 
    
         
            +
                }
         
     | 
| 
      
 238 
     | 
    
         
            +
             
     | 
| 
      
 239 
     | 
    
         
            +
                public static IRubyObject fromVariant(Ruby runtime, Variant variant) {
         
     | 
| 
      
 240 
     | 
    
         
            +
                    if (variant == null) return runtime.getNil();
         
     | 
| 
      
 241 
     | 
    
         
            +
             
     | 
| 
      
 242 
     | 
    
         
            +
                    switch (variant.getType()) {
         
     | 
| 
      
 243 
     | 
    
         
            +
                        case Variant.VariantBoolean:
         
     | 
| 
      
 244 
     | 
    
         
            +
                            return runtime.newBoolean(variant.getBoolean());
         
     | 
| 
      
 245 
     | 
    
         
            +
                        case Variant.VariantDispatch:
         
     | 
| 
      
 246 
     | 
    
         
            +
                            return new RubyWIN32OLE(runtime, Win32oleService.getMetaClass(), variant.getDispatch());
         
     | 
| 
      
 247 
     | 
    
         
            +
                        case Variant.VariantDate:
         
     | 
| 
      
 248 
     | 
    
         
            +
                            return date2ruby(runtime, variant.getDate());
         
     | 
| 
      
 249 
     | 
    
         
            +
                        case Variant.VariantInt:
         
     | 
| 
      
 250 
     | 
    
         
            +
                        case Variant.VariantShort:
         
     | 
| 
      
 251 
     | 
    
         
            +
                            return runtime.newFixnum(variant.getInt());
         
     | 
| 
      
 252 
     | 
    
         
            +
                        case Variant.VariantDouble:
         
     | 
| 
      
 253 
     | 
    
         
            +
                            return runtime.newFloat(variant.getDouble());
         
     | 
| 
      
 254 
     | 
    
         
            +
                        case Variant.VariantFloat:
         
     | 
| 
      
 255 
     | 
    
         
            +
                            return runtime.newFloat(variant.getFloat());
         
     | 
| 
      
 256 
     | 
    
         
            +
                        case Variant.VariantString:
         
     | 
| 
      
 257 
     | 
    
         
            +
                            return runtime.newString(variant.getString());
         
     | 
| 
      
 258 
     | 
    
         
            +
                    }
         
     | 
| 
      
 259 
     | 
    
         
            +
             
     | 
| 
      
 260 
     | 
    
         
            +
                    return JavaUtil.convertJavaToUsableRubyObject(runtime, variant.toJavaObject());
         
     | 
| 
      
 261 
     | 
    
         
            +
                }
         
     | 
| 
      
 262 
     | 
    
         
            +
             
     | 
| 
      
 263 
     | 
    
         
            +
                public static IRubyObject date2ruby(Ruby runtime, Date date) {
         
     | 
| 
      
 264 
     | 
    
         
            +
                    Calendar cal = Calendar.getInstance();
         
     | 
| 
      
 265 
     | 
    
         
            +
             
     | 
| 
      
 266 
     | 
    
         
            +
                    cal.setTime(date);
         
     | 
| 
      
 267 
     | 
    
         
            +
             
     | 
| 
      
 268 
     | 
    
         
            +
                    return runtime.newTime(cal.getTimeInMillis());
         
     | 
| 
      
 269 
     | 
    
         
            +
                }
         
     | 
| 
      
 270 
     | 
    
         
            +
             
     | 
| 
      
 271 
     | 
    
         
            +
                public static String toProgID(String id) {
         
     | 
| 
      
 272 
     | 
    
         
            +
                    if (id != null && id.startsWith("{{") && id.endsWith("}}")) {
         
     | 
| 
      
 273 
     | 
    
         
            +
                        return id.substring(2, id.length() - 2);
         
     | 
| 
      
 274 
     | 
    
         
            +
                    }
         
     | 
| 
      
 275 
     | 
    
         
            +
             
     | 
| 
      
 276 
     | 
    
         
            +
                    return id;
         
     | 
| 
      
 277 
     | 
    
         
            +
                }
         
     | 
| 
      
 278 
     | 
    
         
            +
            }
         
     | 
| 
         @@ -0,0 +1,29 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            package win32ole;
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            import org.racob.com.LibraryLoader;
         
     | 
| 
      
 4 
     | 
    
         
            +
            import java.io.IOException;import java.lang.ref.WeakReference;
         
     | 
| 
      
 5 
     | 
    
         
            +
            import org.jruby.Ruby;
         
     | 
| 
      
 6 
     | 
    
         
            +
            import org.jruby.RubyClass;
         
     | 
| 
      
 7 
     | 
    
         
            +
            import org.jruby.ext.win32ole.RubyWIN32OLE;
         
     | 
| 
      
 8 
     | 
    
         
            +
            import org.jruby.runtime.load.BasicLibraryService;
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
            public class Win32oleService implements BasicLibraryService {
         
     | 
| 
      
 11 
     | 
    
         
            +
                static WeakReference<RubyClass> win32oleClass;
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
                public boolean basicLoad(Ruby runtime) throws IOException {
         
     | 
| 
      
 14 
     | 
    
         
            +
                    LibraryLoader.loadLibrary();
         
     | 
| 
      
 15 
     | 
    
         
            +
                    RubyClass object = runtime.getObject();
         
     | 
| 
      
 16 
     | 
    
         
            +
                    RubyClass win32ole = runtime.defineClass("WIN32OLE", object,
         
     | 
| 
      
 17 
     | 
    
         
            +
                            RubyWIN32OLE.WIN32OLE_ALLOCATOR);
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
                    win32ole.defineAnnotatedMethods(RubyWIN32OLE.class);
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
                    win32oleClass = new WeakReference<RubyClass>(win32ole);
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
                    return true;
         
     | 
| 
      
 24 
     | 
    
         
            +
                }
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
                public static RubyClass getMetaClass() {
         
     | 
| 
      
 27 
     | 
    
         
            +
                    return win32oleClass.get();
         
     | 
| 
      
 28 
     | 
    
         
            +
                }
         
     | 
| 
      
 29 
     | 
    
         
            +
            }
         
     | 
    
        metadata
    ADDED
    
    | 
         @@ -0,0 +1,113 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            --- !ruby/object:Gem::Specification 
         
     | 
| 
      
 2 
     | 
    
         
            +
            name: jruby-win32ole
         
     | 
| 
      
 3 
     | 
    
         
            +
            version: !ruby/object:Gem::Version 
         
     | 
| 
      
 4 
     | 
    
         
            +
              hash: 63
         
     | 
| 
      
 5 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 6 
     | 
    
         
            +
              segments: 
         
     | 
| 
      
 7 
     | 
    
         
            +
              - 0
         
     | 
| 
      
 8 
     | 
    
         
            +
              - 8
         
     | 
| 
      
 9 
     | 
    
         
            +
              - 0
         
     | 
| 
      
 10 
     | 
    
         
            +
              version: 0.8.0
         
     | 
| 
      
 11 
     | 
    
         
            +
            platform: ruby
         
     | 
| 
      
 12 
     | 
    
         
            +
            authors: 
         
     | 
| 
      
 13 
     | 
    
         
            +
            - Thomas E. Enebo
         
     | 
| 
      
 14 
     | 
    
         
            +
            autorequire: 
         
     | 
| 
      
 15 
     | 
    
         
            +
            bindir: bin
         
     | 
| 
      
 16 
     | 
    
         
            +
            cert_chain: []
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
            date: 2010-10-21 00:00:00 -05:00
         
     | 
| 
      
 19 
     | 
    
         
            +
            default_executable: 
         
     | 
| 
      
 20 
     | 
    
         
            +
            dependencies: []
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
            description: A Gem for win32ole support on JRuby
         
     | 
| 
      
 23 
     | 
    
         
            +
            email: tom.enebo@gmail.com
         
     | 
| 
      
 24 
     | 
    
         
            +
            executables: 
         
     | 
| 
      
 25 
     | 
    
         
            +
            - make_data.rb
         
     | 
| 
      
 26 
     | 
    
         
            +
            - sample
         
     | 
| 
      
 27 
     | 
    
         
            +
            extensions: []
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
            extra_rdoc_files: []
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
            files: 
         
     | 
| 
      
 32 
     | 
    
         
            +
            - .gitignore
         
     | 
| 
      
 33 
     | 
    
         
            +
            - Gemfile
         
     | 
| 
      
 34 
     | 
    
         
            +
            - README
         
     | 
| 
      
 35 
     | 
    
         
            +
            - Rakefile
         
     | 
| 
      
 36 
     | 
    
         
            +
            - VERSION
         
     | 
| 
      
 37 
     | 
    
         
            +
            - bin/make_data.rb
         
     | 
| 
      
 38 
     | 
    
         
            +
            - bin/sample
         
     | 
| 
      
 39 
     | 
    
         
            +
            - build.xml
         
     | 
| 
      
 40 
     | 
    
         
            +
            - jruby-win32ole.gemspec
         
     | 
| 
      
 41 
     | 
    
         
            +
            - lib/jruby-win32ole.rb
         
     | 
| 
      
 42 
     | 
    
         
            +
            - lib/jruby-win32ole/version.rb
         
     | 
| 
      
 43 
     | 
    
         
            +
            - lib/racob-x64.dll
         
     | 
| 
      
 44 
     | 
    
         
            +
            - lib/racob-x86.dll
         
     | 
| 
      
 45 
     | 
    
         
            +
            - lib/racob.jar
         
     | 
| 
      
 46 
     | 
    
         
            +
            - lib/win32ole/utils.rb
         
     | 
| 
      
 47 
     | 
    
         
            +
            - lib/win32ole/win32ole.jar
         
     | 
| 
      
 48 
     | 
    
         
            +
            - lib/win32ole/win32ole_error.rb
         
     | 
| 
      
 49 
     | 
    
         
            +
            - lib/win32ole/win32ole_event.rb
         
     | 
| 
      
 50 
     | 
    
         
            +
            - lib/win32ole/win32ole_method.rb
         
     | 
| 
      
 51 
     | 
    
         
            +
            - lib/win32ole/win32ole_param.rb
         
     | 
| 
      
 52 
     | 
    
         
            +
            - lib/win32ole/win32ole_ruby.rb
         
     | 
| 
      
 53 
     | 
    
         
            +
            - lib/win32ole/win32ole_type.rb
         
     | 
| 
      
 54 
     | 
    
         
            +
            - lib/win32ole/win32ole_typelib.rb
         
     | 
| 
      
 55 
     | 
    
         
            +
            - lib/win32ole/win32ole_variable.rb
         
     | 
| 
      
 56 
     | 
    
         
            +
            - lib/win32ole/win32ole_variant.rb
         
     | 
| 
      
 57 
     | 
    
         
            +
            - nbproject/build-impl.xml
         
     | 
| 
      
 58 
     | 
    
         
            +
            - nbproject/genfiles.properties
         
     | 
| 
      
 59 
     | 
    
         
            +
            - nbproject/private/config.properties
         
     | 
| 
      
 60 
     | 
    
         
            +
            - nbproject/private/private.properties
         
     | 
| 
      
 61 
     | 
    
         
            +
            - nbproject/private/private.xml
         
     | 
| 
      
 62 
     | 
    
         
            +
            - nbproject/project.properties
         
     | 
| 
      
 63 
     | 
    
         
            +
            - nbproject/project.xml
         
     | 
| 
      
 64 
     | 
    
         
            +
            - samples/browser_connect.rb
         
     | 
| 
      
 65 
     | 
    
         
            +
            - samples/const_load.rb
         
     | 
| 
      
 66 
     | 
    
         
            +
            - samples/dir_enum_bench.rb
         
     | 
| 
      
 67 
     | 
    
         
            +
            - samples/dispatch_bench.rb
         
     | 
| 
      
 68 
     | 
    
         
            +
            - samples/file_system_object.rb
         
     | 
| 
      
 69 
     | 
    
         
            +
            - samples/fs.rb
         
     | 
| 
      
 70 
     | 
    
         
            +
            - samples/ie_plus_events.rb
         
     | 
| 
      
 71 
     | 
    
         
            +
            - samples/ie_simple.rb
         
     | 
| 
      
 72 
     | 
    
         
            +
            - samples/ie_simple_clsid.rb
         
     | 
| 
      
 73 
     | 
    
         
            +
            - samples/sbem.rb
         
     | 
| 
      
 74 
     | 
    
         
            +
            - samples/small_enum_bench.rb
         
     | 
| 
      
 75 
     | 
    
         
            +
            - src/org/jruby/ext/win32ole/RubyInvocationProxy.java
         
     | 
| 
      
 76 
     | 
    
         
            +
            - src/org/jruby/ext/win32ole/RubyWIN32OLE.java
         
     | 
| 
      
 77 
     | 
    
         
            +
            - src/win32ole/Win32oleService.java
         
     | 
| 
      
 78 
     | 
    
         
            +
            has_rdoc: true
         
     | 
| 
      
 79 
     | 
    
         
            +
            homepage: http://github.com/enebo/jruby-win32ole
         
     | 
| 
      
 80 
     | 
    
         
            +
            licenses: []
         
     | 
| 
      
 81 
     | 
    
         
            +
             
     | 
| 
      
 82 
     | 
    
         
            +
            post_install_message: 
         
     | 
| 
      
 83 
     | 
    
         
            +
            rdoc_options: []
         
     | 
| 
      
 84 
     | 
    
         
            +
             
     | 
| 
      
 85 
     | 
    
         
            +
            require_paths: 
         
     | 
| 
      
 86 
     | 
    
         
            +
            - lib
         
     | 
| 
      
 87 
     | 
    
         
            +
            required_ruby_version: !ruby/object:Gem::Requirement 
         
     | 
| 
      
 88 
     | 
    
         
            +
              none: false
         
     | 
| 
      
 89 
     | 
    
         
            +
              requirements: 
         
     | 
| 
      
 90 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 91 
     | 
    
         
            +
                - !ruby/object:Gem::Version 
         
     | 
| 
      
 92 
     | 
    
         
            +
                  hash: 3
         
     | 
| 
      
 93 
     | 
    
         
            +
                  segments: 
         
     | 
| 
      
 94 
     | 
    
         
            +
                  - 0
         
     | 
| 
      
 95 
     | 
    
         
            +
                  version: "0"
         
     | 
| 
      
 96 
     | 
    
         
            +
            required_rubygems_version: !ruby/object:Gem::Requirement 
         
     | 
| 
      
 97 
     | 
    
         
            +
              none: false
         
     | 
| 
      
 98 
     | 
    
         
            +
              requirements: 
         
     | 
| 
      
 99 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 100 
     | 
    
         
            +
                - !ruby/object:Gem::Version 
         
     | 
| 
      
 101 
     | 
    
         
            +
                  hash: 3
         
     | 
| 
      
 102 
     | 
    
         
            +
                  segments: 
         
     | 
| 
      
 103 
     | 
    
         
            +
                  - 0
         
     | 
| 
      
 104 
     | 
    
         
            +
                  version: "0"
         
     | 
| 
      
 105 
     | 
    
         
            +
            requirements: []
         
     | 
| 
      
 106 
     | 
    
         
            +
             
     | 
| 
      
 107 
     | 
    
         
            +
            rubyforge_project: jruby-win32ole
         
     | 
| 
      
 108 
     | 
    
         
            +
            rubygems_version: 1.3.7
         
     | 
| 
      
 109 
     | 
    
         
            +
            signing_key: 
         
     | 
| 
      
 110 
     | 
    
         
            +
            specification_version: 3
         
     | 
| 
      
 111 
     | 
    
         
            +
            summary: A Gem for win32ole support on JRuby
         
     | 
| 
      
 112 
     | 
    
         
            +
            test_files: []
         
     | 
| 
      
 113 
     | 
    
         
            +
             
     |