Ejemplo n.º 1
0
        /// <exception cref="VariantException"></exception>
        /// <exception cref="TjsException"></exception>
        public override int FuncCall(int flag, string membername, Variant result, Variant
                                     [] param, Dispatch2 objthis)
        {
            if (membername != null)
            {
                return(base.FuncCall(flag, membername, result, param, objthis));
            }
            if (param.Length < mParamTypes.Length)
            {
                return(Error.E_INVALIDPARAM);
            }
            // パラメータが少ない
            if (result != null)
            {
                result.Clear();
            }
            object self;

            if (mIsStatic)
            {
                self = null;
            }
            else
            {
                // static 时は null
                if (objthis == null)
                {
                    return(Error.E_NATIVECLASSCRASH);
                }
                NativeJavaInstance ni = (NativeJavaInstance)objthis.GetNativeInstance(mClassID);
                if (ni == null)
                {
                    return(Error.E_FAIL);
                }
                self = ni.GetNativeObject();
                if (self == null)
                {
                    return(Error.E_NATIVECLASSCRASH);
                }
            }
            int er = Error.S_OK;

            object[] args = NativeJavaClass.VariantArrayToJavaObjectArray(param, mParamTypes);
            try
            {
                object ret = mProcess.Invoke(self, args);
                if (result != null)
                {
                    NativeJavaClass.JavaObjectToVariant(result, mReturnType, ret);
                }
            }
            catch (ArgumentException)
            {
                er = Error.E_INVALIDPARAM;
            }
            catch (MemberAccessException)
            {
                er = Error.E_ACCESSDENIED;
            }
            catch (TargetInvocationException e)
            {
                Exception t = e.InnerException;
                if (t is VariantException)
                {
                    throw (VariantException)t;
                }
                else
                {
                    if (t is TjsException)
                    {
                        throw (TjsException)t;
                    }
                    else
                    {
                        throw new TjsException(t.ToString());
                    }
                }
            }
            return(er);
        }
Ejemplo n.º 2
0
        /// <exception cref="VariantException"></exception>
        /// <exception cref="TjsException"></exception>
        public override int PropGet(int flag, string membername, Variant result, Dispatch2
                                    objthis)
        {
            if (membername != null)
            {
                return(base.PropGet(flag, membername, result, objthis));
            }
            if (result == null)
            {
                return(Error.E_FAIL);
            }
            if (mGet == null)
            {
                return(Error.E_ACCESSDENIED);
            }
            object self;

            if (mIsStaticGet)
            {
                self = null;
            }
            else
            {
                // static 时は null
                if (objthis == null)
                {
                    return(Error.E_NATIVECLASSCRASH);
                }
                NativeJavaInstance ni = (NativeJavaInstance)objthis.GetNativeInstance(mClassID);
                if (ni == null)
                {
                    return(Error.E_FAIL);
                }
                self = ni.GetNativeObject();
                if (self == null)
                {
                    return(Error.E_NATIVECLASSCRASH);
                }
            }
            int er = Error.S_OK;

            try
            {
                object ret = mGet.Invoke(self, new object[] {});
                NativeJavaClass.JavaObjectToVariant(result, mReturnType, ret);
            }
            catch (ArgumentException)
            {
                er = Error.E_INVALIDPARAM;
            }
            catch (MemberAccessException)
            {
                er = Error.E_ACCESSDENIED;
            }
            catch (TargetInvocationException e)
            {
                Exception t = e.InnerException;
                if (t is VariantException)
                {
                    throw (VariantException)t;
                }
                else
                {
                    if (t is TjsException)
                    {
                        throw (TjsException)t;
                    }
                    else
                    {
                        throw new TjsException(t.ToString());
                    }
                }
            }
            return(er);
        }