Beispiel #1
0
        public PythonLayer(PythonScriptHost host, string code, string name)
        {
            Name = name;
            Code = code;
            Host = host;

            string[] codeWithoutWhitespace = code.Split(new char[] { ' ', '\n' }, StringSplitOptions.RemoveEmptyEntries);
            string alltokens = "";

            foreach (string token in codeWithoutWhitespace)
            {
                alltokens += token;
            }

            _id = alltokens.GetHashCode().ToString();

                _scope = host.CreateScriptSource(code, name);

                _annotionArgs = new PythonAnnotatedNodeArgs();

                if (_scope.ContainsVariable(_processannotations))
                {
                    _processAnnotationsFunc = _scope.GetVariable(_processannotations);
                }

                if (_scope.ContainsVariable(_interpret))
                {
                    _interpretFunc = _scope.GetVariable(_interpret);
                }

                //if (_scope.ContainsVariable(_annotationlibs))
                //{
                //    _getAnnotationLibsFunc = _scope.GetVariable(_annotationlibs);
                //}

                if (_scope.ContainsVariable(_afterinterpret))
                {
                    _afterInterpretFunc = _scope.GetVariable(_afterinterpret);
                }

                //if (_scope.ContainsVariable(_init))
                //{
                //    _initFunc = _scope.GetVariable(_init);
                //}


        }
Beispiel #2
0
        public PythonLayer(PythonScriptHost host, string code, string name)
        {
            Name = name;
            Code = code;
            Host = host;

            string[] codeWithoutWhitespace = code.Split(new char[] { ' ', '\n' }, StringSplitOptions.RemoveEmptyEntries);
            string   alltokens             = "";

            foreach (string token in codeWithoutWhitespace)
            {
                alltokens += token;
            }

            _id = alltokens.GetHashCode().ToString();

            _scope = host.CreateScriptSource(code, name);

            _annotionArgs = new PythonAnnotatedNodeArgs();

            if (_scope.ContainsVariable(_processannotations))
            {
                _processAnnotationsFunc = _scope.GetVariable(_processannotations);
            }

            if (_scope.ContainsVariable(_interpret))
            {
                _interpretFunc = _scope.GetVariable(_interpret);
            }

            //if (_scope.ContainsVariable(_annotationlibs))
            //{
            //    _getAnnotationLibsFunc = _scope.GetVariable(_annotationlibs);
            //}

            if (_scope.ContainsVariable(_afterinterpret))
            {
                _afterInterpretFunc = _scope.GetVariable(_afterinterpret);
            }

            //if (_scope.ContainsVariable(_init))
            //{
            //    _initFunc = _scope.GetVariable(_init);
            //}
        }