Example #1
0
        private void WriteThrow(MagickMethod method)
        {
            WriteThrowStart();

            if (method.CreatesInstance)
            {
                WriteLine("IntPtr result;");
            }
            else if (!method.ReturnType.IsVoid)
            {
                WriteLine(method.ReturnType.Native + " result;");
            }

            string arguments = GetNativeArgumentsCall(method);
            string action    = "NativeMethods.{0}." + Class.Name + "_" + method.Name + "(" + arguments + ");";

            if (!method.ReturnType.IsVoid || method.CreatesInstance)
            {
                action = "result = " + action;
            }
            WriteNativeIfContent(action);

            WriteCreateOut(method.Arguments);

            string cleanupString = CreateCleanupString(method);

            if (!string.IsNullOrEmpty(cleanupString))
            {
                WriteCleanup(cleanupString);
            }
            else if ((method.CreatesInstance) && !Class.IsConst)
            {
                WriteLine("CheckException(exception, result);");
            }
            else
            {
                WriteCheckException(true);
            }

            if (method.CreatesInstance && method.ReturnType.IsVoid)
            {
                WriteLine("Instance = result;");
            }
            else
            {
                WriteReturn(method.ReturnType);
            }
        }
Example #2
0
        protected string GetNativeArgumentsDeclaration(MagickMethod method)
        {
            string arguments = GetNativeArgumentsDeclaration(method.Arguments);

            if (Class.IsStatic || method.IsStatic)
            {
                return(arguments);
            }
            else if (string.IsNullOrEmpty(arguments))
            {
                return("IntPtr Instance");
            }
            else
            {
                return("IntPtr Instance, " + arguments);
            }
        }
Example #3
0
        private string CreateCleanupString(MagickMethod method)
        {
            if (method.Cleanup == null)
            {
                if (!Class.HasInstance && !method.ReturnType.IsVoid)
                {
                    return("Dispose(result);");
                }

                return(null);
            }

            var cleanup = method.Cleanup;

            string result = cleanup.Name + "(result";

            if (cleanup.Arguments.Count() > 0)
            {
                result += ", " + string.Join(", ", cleanup.Arguments);
            }
            return(result + ");");
        }