Example #1
0
        public static DLLModule GetModule(string dllModuleName)
        {
            string moduleFileName = System.IO.Path.GetFileName(dllModuleName);

            if (!Modules.ContainsKey(moduleFileName))
            {
                try
                {
                    Modules.Add(moduleFileName, helpers[FFILanguage.CSharp].getModule(dllModuleName));
                }
                catch
                {
                    //try loading c++
                    try
                    {
                        Modules.Add(moduleFileName, helpers[FFILanguage.CPlusPlus].getModule(dllModuleName));
                    }
                    catch
                    {
                        throw;
                    }
                }
            }

            DLLModule dllModule = Modules[moduleFileName];

            return(dllModule);
        }
Example #2
0
        public static DLLModule GetModule(string dllModuleName)
        {
            string moduleFileName = System.IO.Path.GetFileName(dllModuleName);

            if (!Modules.ContainsKey(moduleFileName))
            {
                try
                {
                    Modules.Add(moduleFileName, helpers[FFILanguage.CSharp].getModule(dllModuleName));
                }
                catch (DynamoServices.AssemblyBlockedException exception)
                {
                    // this exception is caught upstream after displaying a failed load library warning to the user.
                    throw exception;
                }
                catch (Exception)
                {
                    //try loading c++
                    try
                    {
                        Modules.Add(moduleFileName, helpers[FFILanguage.CPlusPlus].getModule(dllModuleName));
                    }
                    catch
                    {
                        throw;
                    }
                }
            }

            DLLModule dllModule = Modules[moduleFileName];

            return(dllModule);
        }
        private CodeBlockNode ImportCodeBlock(string importModuleName, string typeName, string alias, CodeBlockNode refNode)
        {
            DLLModule dllModule = null;
            string    extension = System.IO.Path.GetExtension(importModuleName).ToLower();

            if (extension == ".dll" || extension == ".exe")
            {
                try
                {
                    dllModule = DLLFFIHandler.GetModule(importModuleName);
                }
                catch (DynamoServices.AssemblyBlockedException ex)
                {
                    // this exception is caught upstream after displaying a failed load library warning to the user.
                    throw ex;
                }
                catch (Exception)
                {
                    _coreObj.LogSemanticError(string.Format(Resources.FailedToImport, importModuleName), _coreObj.CurrentDSFileName, curLine, curCol);
                }
            }


            CodeBlockNode codeBlockNode = refNode;

            if (null != dllModule)
            {
                codeBlockNode = dllModule.ImportCodeBlock(typeName, alias, refNode);
                Type type = dllModule.GetExtensionAppType();
                if (type != null)
                {
                    _coreObj.AddDLLExtensionAppType(type);
                }
            }
            else if (extension == ".ds")
            {
                string origDSFile = _coreObj.CurrentDSFileName;
                _coreObj.CurrentDSFileName = System.IO.Path.GetFullPath(importModuleName);
                codeBlockNode = ImportDesignScriptFile(_coreObj.CurrentDSFileName, typeName, alias);
                _coreObj.CurrentDSFileName = origDSFile;
            }


            return(codeBlockNode);
        }
Example #4
0
        private CodeBlockNode ImportCodeBlock(string importModuleName, string typeName, string alias, CodeBlockNode refNode)
        {
            DLLModule dllModule = null;
            string    extension = System.IO.Path.GetExtension(importModuleName).ToLower();

            if (extension == ".dll" || extension == ".exe")
            {
                try
                {
                    dllModule = DLLFFIHandler.GetModule(importModuleName);
                }
                catch
                {
                    _coreObj.LogSemanticError(string.Format(Resources.FailedToImport, importModuleName), _coreObj.CurrentDSFileName, curLine, curCol);
                }
            }


            CodeBlockNode codeBlockNode = refNode;

            if (null != dllModule)
            {
                codeBlockNode = dllModule.ImportCodeBlock(typeName, alias, refNode);
                Type type = dllModule.GetExtensionAppType();
                if (type != null)
                {
                    ProtoCore.RuntimeCore runtimeCore = _coreObj.__TempCoreHostForRefactoring;
                    FFIExecutionManager.Instance.RegisterExtensionApplicationType(runtimeCore, type);
                }
            }
            else if (extension == ".ds")
            {
                string origDSFile = _coreObj.CurrentDSFileName;
                _coreObj.CurrentDSFileName = System.IO.Path.GetFullPath(importModuleName);
                codeBlockNode = ImportDesignScriptFile(_coreObj.CurrentDSFileName, typeName, alias);
                _coreObj.CurrentDSFileName = origDSFile;
            }


            return(codeBlockNode);
        }
        private CodeBlockNode ImportCodeBlock(string importModuleName, string typeName, string alias, CodeBlockNode refNode)
        {
            DLLModule dllModule = null;
            string    extension = System.IO.Path.GetExtension(importModuleName).ToLower();

            if (extension == ".dll" || extension == ".exe")
            {
                try
                {
                    dllModule = DLLFFIHandler.GetModule(importModuleName);
                }
                catch
                {
                    compileState.BuildStatus.LogSemanticError(string.Format("Failed to import {0}", importModuleName), compileState.CurrentDSFileName, curLine, curCol);
                }
            }


            CodeBlockNode codeBlockNode = refNode;

            if (null != dllModule)
            {
                codeBlockNode = dllModule.ImportCodeBlock(typeName, alias, refNode);
                Type type = dllModule.GetExtensionAppType();
                if (type != null)
                {
                    FFIExecutionManager.Instance.RegisterExtensionApplicationType(compileState, type);
                }
            }
            else if (extension == ".ds")
            {
                string origDSFile = compileState.CurrentDSFileName;
                compileState.CurrentDSFileName = System.IO.Path.GetFullPath(importModuleName);
                codeBlockNode = ImportDesignScriptFile(importModuleName, typeName, alias);
                compileState.CurrentDSFileName = origDSFile;
            }


            return(codeBlockNode);
        }
Example #6
0
        public override FFIFunctionPointer GetFunctionPointer(string dllModuleName, string className, string functionName, List <ProtoCore.Type> parameterTypes, ProtoCore.Type returnType)
        {
            DLLModule dllModule = GetModule(dllModuleName);

            return(dllModule.GetFunctionPointer(className, functionName, parameterTypes, returnType));
        }