Ejemplo n.º 1
0
		private static DynValue GetStandardFile(Script S, StandardFileType file)
		{
			Table R = S.Registry;

			DynValue ff = R.Get("853BEAAF298648839E2C99D005E1DF94_STD_" + file.ToString());
			return ff;
		}
Ejemplo n.º 2
0
		public static void SetDefaultFile(Script script, StandardFileType file, Stream stream)
		{
			if (file == StandardFileType.StdIn)
				SetDefaultFile(script, file, StandardIOFileUserDataBase.CreateInputStream(stream));
			else
				SetDefaultFile(script, file, StandardIOFileUserDataBase.CreateOutputStream(stream));
		}
Ejemplo n.º 3
0
        private static DynValue HandleDefaultStreamSetter(ScriptExecutionContext executionContext,
                                                          CallbackArguments args, StandardFileType defaultFiles)
        {
            if (args.Count == 0 || args[0].IsNil())
            {
                var file = GetDefaultFile(executionContext, defaultFiles);
                return(UserData.Create(file));
            }

            FileUserDataBase inp;

            if (args[0].Type == DataType.String || args[0].Type == DataType.Number)
            {
                string fileName = args[0].CastToString();
                inp = Open(executionContext, fileName, GetUTF8Encoding(),
                           defaultFiles == StandardFileType.StdIn ? "r" : "w");
            }
            else
            {
                inp = args.AsUserData <FileUserDataBase>(0, defaultFiles == StandardFileType.StdIn ? "input" : "output");
            }

            SetDefaultFile(executionContext, defaultFiles, inp);

            return(UserData.Create(inp));
        }
Ejemplo n.º 4
0
        private static DynValue GetStandardFile(Script S, StandardFileType file)
        {
            var R = S.Registry;

            var ff = R.Get("853BEAAF298648839E2C99D005E1DF94_STD_" + file);

            return(ff);
        }
Ejemplo n.º 5
0
		static FileUserDataBase GetDefaultFile(ScriptExecutionContext executionContext, StandardFileType file)
		{
			Table R = executionContext.GetScript().Registry;

			DynValue ff = R.Get("853BEAAF298648839E2C99D005E1DF94_" + file.ToString());

			if (ff.IsNil())
			{
				ff = GetStandardFile(executionContext.GetScript(), file);
			}

			return ff.CheckUserDataType<FileUserDataBase>("getdefaultfile(" + file.ToString() + ")");
		}
Ejemplo n.º 6
0
		private static void SetStandardFile(Script S, StandardFileType file, Stream optionsStream)
		{
			Table R = S.Registry;

			optionsStream = optionsStream ?? Script.GlobalOptions.Platform.IO_GetStandardStream(file);

			FileUserDataBase udb = null;

			if (file == StandardFileType.StdIn)
				udb = StandardIOFileUserDataBase.CreateInputStream(optionsStream);
			else
				udb = StandardIOFileUserDataBase.CreateOutputStream(optionsStream);

			R.Set("853BEAAF298648839E2C99D005E1DF94_STD_" + file.ToString(), UserData.Create(udb));
		}
Ejemplo n.º 7
0
        /// <summary>
        /// Gets a standard stream (stdin, stdout, stderr).
        /// </summary>
        /// <param name="type">The type.</param>
        /// <returns></returns>
        /// <exception cref="System.ArgumentException">type</exception>
        public override Stream IO_GetStandardStream(StandardFileType type)
        {
            switch (type)
            {
            case StandardFileType.StdIn:
                return(Console.OpenStandardInput());

            case StandardFileType.StdOut:
                return(Console.OpenStandardOutput());

            case StandardFileType.StdErr:
                return(Console.OpenStandardError());

            default:
                throw new ArgumentException("type");
            }
        }
Ejemplo n.º 8
0
        public override Stream IO_GetStandardStream(StandardFileType type)
        {
            switch (type)
            {
            case StandardFileType.StdIn:
                return(Console.OpenStandardInput());

            case StandardFileType.StdOut:
                return(Console.OpenStandardOutput());

            case StandardFileType.StdErr:
                return(Console.OpenStandardError());

            default:
                throw new InvalidOperationException($"Unrecognized StandardFileType {type}");
            }
        }
Ejemplo n.º 9
0
 /// <summary>
 /// Gets a standard stream (stdin, stdout, stderr).
 /// </summary>
 /// <param name="type">The type.</param>
 /// <returns></returns>
 public abstract Stream IO_GetStandardStream(StandardFileType type);
Ejemplo n.º 10
0
        internal static void SetDefaultFile(Script script, StandardFileType file, FileUserDataBase fileHandle)
        {
            Table R = script.Registry;

            R.Set("853BEAAF298648839E2C99D005E1DF94_" + file.ToString(), UserData.Create(fileHandle));
        }
Ejemplo n.º 11
0
 static void SetDefaultFile(ScriptExecutionContext executionContext, StandardFileType file, FileUserDataBase fileHandle)
 {
     SetDefaultFile(executionContext.GetScript(), file, fileHandle);
 }
Ejemplo n.º 12
0
 public override Stream IO_GetStandardStream(StandardFileType type)
 {
     return(null);
 }
Ejemplo n.º 13
0
        private static FileUserDataBase GetDefaultFile(ScriptExecutionContext executionContext, StandardFileType file)
        {
            var R = executionContext.GetScript().Registry;

            var ff = R.Get("853BEAAF298648839E2C99D005E1DF94_" + file);

            if (ff.IsNil())
            {
                ff = GetStandardFile(executionContext.GetScript(), file);
            }

            return(ff.CheckUserDataType <FileUserDataBase>("getdefaultfile(" + file + ")"));
        }
Ejemplo n.º 14
0
		/// <summary>
		/// Gets a standard stream (stdin, stdout, stderr).
		/// LimitedPlatformAccessorBase does NOT offer a meaningful implementation of this method and
		/// thus does not support 'io' and 'os' modules.
		/// </summary>
		/// <param name="type">The type.</param>
		/// <returns></returns>
		/// <exception cref="System.NotImplementedException">The current platform accessor does not support 'io' and 'os' operations. Provide your own implementation of platform to work around this limitation, if needed.</exception>
		public override System.IO.Stream IO_GetStandardStream(StandardFileType type)
		{
			throw new NotImplementedException("The current platform accessor does not support 'io' and 'os' operations. Provide your own implementation of platform to work around this limitation, if needed.");
		}
		/// <summary>
		/// Gets a standard stream (stdin, stdout, stderr).
		/// </summary>
		/// <param name="type">The type.</param>
		/// <returns></returns>
		public abstract Stream IO_GetStandardStream(StandardFileType type);
 public override Stream IO_GetStandardStream(StandardFileType type)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 17
0
		private static DynValue HandleDefaultStreamSetter(ScriptExecutionContext executionContext, CallbackArguments args, StandardFileType defaultFiles)
		{
			if (args.Count == 0 || args[0].IsNil())
			{
				var file = GetDefaultFile(executionContext, defaultFiles);
				return UserData.Create(file);
			}

			FileUserDataBase inp = null;

			if (args[0].Type == DataType.String || args[0].Type == DataType.Number)
			{
				string fileName = args[0].CastToString();
				inp = Open(executionContext, fileName, GetUTF8Encoding(), defaultFiles == StandardFileType.StdIn ? "r" : "w");
			}
			else
			{
				inp = args.AsUserData<FileUserDataBase>(0, defaultFiles == StandardFileType.StdIn ? "input" : "output", false);
			}

			SetDefaultFile(executionContext, defaultFiles, inp);

			return UserData.Create(inp);
		}
		public override Stream IO_GetStandardStream(StandardFileType type)
		{
			throw new NotImplementedException();
		}
Ejemplo n.º 19
0
		/// <summary>
		/// Gets a standard stream (stdin, stdout, stderr).
		/// </summary>
		/// <param name="type">The type.</param>
		/// <returns></returns>
		/// <exception cref="System.ArgumentException">type</exception>
		public override Stream IO_GetStandardStream(StandardFileType type)
		{
			switch (type)
			{
				case StandardFileType.StdIn:
					return Console.OpenStandardInput();
				case StandardFileType.StdOut:
					return Console.OpenStandardOutput();
				case StandardFileType.StdErr:
					return Console.OpenStandardError();
				default:
					throw new ArgumentException("type");
			}
		}
Ejemplo n.º 20
0
		static void SetDefaultFile(ScriptExecutionContext executionContext, StandardFileType file, FileUserDataBase fileHandle)
		{
			SetDefaultFile(executionContext.GetScript(), file, fileHandle);
		}
        public Stream IO_GetStandardStream(StandardFileType type)
        {
            // TODO need to look into what this is

            throw new NotImplementedException();
        }
Ejemplo n.º 22
0
		internal static void SetDefaultFile(Script script, StandardFileType file, FileUserDataBase fileHandle)
		{
			Table R = script.Registry;
			R.Set("853BEAAF298648839E2C99D005E1DF94_" + file.ToString(), UserData.Create(fileHandle));
		}
Ejemplo n.º 23
0
 /// <summary>
 /// Gets a standard stream (stdin, stdout, stderr).
 /// LimitedPlatformAccessorBase does NOT offer a meaningful implementation of this method and
 /// thus does not support 'io' and 'os' modules.
 /// </summary>
 /// <param name="type">The type.</param>
 /// <exception cref="System.NotImplementedException">The current platform accessor does not support 'io' and 'os' operations. Provide your own implementation of platform to work around this limitation, if needed.</exception>
 public override Stream IO_GetStandardStream(StandardFileType type)
 {
     throw new NotImplementedException(
               "The current platform accessor does not support 'io' and 'os' operations. Provide your own implementation of platform to work around this limitation, if needed.");
 }
 public Stream IO_GetStandardStream(StandardFileType type)
 {
     throw new System.NotImplementedException();
 }