Пример #1
0
        public virtual EntityRecord GetRecord(EntityKey primaryKey, LoadFlags flags = LoadFlags.Default)
        {
            if (primaryKey == null || primaryKey.IsNull())
            {
                return(null);
            }
            var record = GetLoadedRecord(primaryKey);

            if (record != null)
            {
                if (record.Status == EntityStatus.Stub && flags.IsSet(LoadFlags.Load))
                {
                    record.Reload();
                }
                return(record);
            }
            // TODO: review returning Record stub in the context of SecureSession.
            // We might have security hole here if user is not authorized to access the record
            if (flags.IsSet(LoadFlags.Stub))
            {
                return(CreateStub(primaryKey));
            }
            if (!flags.IsSet(LoadFlags.Load))
            {
                return(null);
            }
            //Otherwise, load it
            var ent = this.SelectByPrimaryKey(primaryKey.KeyInfo.Entity, primaryKey.Values);

            return(ent?.Record);
        }
Пример #2
0
        private void LoadV2(string s, ref LoadFlags flags)
        {
            this.State.Load(s);
            if (this.State.Inventory.WeightCurrent == 0 && this.State.Inventory.WeightMax1 == 0 && this.State.Inventory.WeightMax2 == 0)
            {
                flags |= LoadFlags.V2InventoryWeightsMissing;
            }

            if (this.State.ObjectID.Equals(Guid.Empty) || this.State.Inventory.Items.Any(i => i.ObjectID.Equals(Guid.Empty)) || this.State.Spellbook.AllSpells.Any(sp => sp.ObjectID.Equals(Guid.Empty)))
            {
                flags |= LoadFlags.V2NoObjectIDs;
            }

            if (this._tempLoadObject.ContainsKey("Extras") && ((JObject)this._tempLoadObject["Extras"]).ContainsKey("Feats"))
            {
                flags |= LoadFlags.V2OldFeats | LoadFlags.KeepLoadObject;
            }

            if (this.State.Inventory.Items.Any(i => !string.IsNullOrEmpty(i.ImageIndex) && i.ImageIndex[0] != '\\') ||
                this.State.Extras.FeatsArray.Any(i => !string.IsNullOrEmpty(i.ImageIndex) && i.ImageIndex[0] != '\\') ||
                this.State.Extras.TraitsArray.Any(i => !string.IsNullOrEmpty(i.ImageIndex) && i.ImageIndex[0] != '\\') ||
                this.State.Spellbook.AllSpells.Any(i => !string.IsNullOrEmpty(i.ImageIndex) && i.ImageIndex[0] != '\\'))
            {
                flags |= LoadFlags.V2OldImageModels;
            }
        }
Пример #3
0
        private ScriptCode /*!*/ CompileRubySource(SourceUnit /*!*/ sourceUnit, LoadFlags flags)
        {
            Assert.NotNull(sourceUnit);

            // TODO: check file timestamp
            string       fullPath = Platform.GetFullPath(sourceUnit.Path);
            CompiledFile compiledFile;

            if (TryGetCompiledFile(fullPath, out compiledFile))
            {
                Utils.Log(String.Format("{0}: {1}", ++_cacheHitCount, sourceUnit.Path), "LOAD_CACHED");

                return(compiledFile.CompiledCode);
            }
            else
            {
                Utils.Log(String.Format("{0}: {1}", ++_compiledFileCount, sourceUnit.Path), "LOAD_COMPILED");

                RubyCompilerOptions options = new RubyCompilerOptions(_context.RubyOptions)
                {
                    FactoryKind = (flags & LoadFlags.LoadIsolated) != 0 ? TopScopeFactoryKind.WrappedFile : TopScopeFactoryKind.File
                };

                long       ts1          = Stopwatch.GetTimestamp();
                ScriptCode compiledCode = sourceUnit.Compile(options, _context.RuntimeErrorSink);
                long       ts2          = Stopwatch.GetTimestamp();
                Interlocked.Add(ref _ScriptCodeGenerationTimeTicks, ts2 - ts1);

                AddCompiledFile(fullPath, compiledCode);

                return(compiledCode);
            }
        }
Пример #4
0
 private void FileLoaded(MutableString /*!*/ path, LoadFlags flags)
 {
     if ((flags & LoadFlags.LoadOnce) != 0)
     {
         AddLoadedFile(path);
     }
 }
Пример #5
0
        private ScriptCode /*!*/ CompileRubySource(SourceUnit /*!*/ sourceUnit, LoadFlags flags)
        {
            Assert.NotNull(sourceUnit);

            // TODO: check file timestamp
            string fullPath = Platform.GetFullPath(sourceUnit.Path);

#if FEATURE_FILESYSTEM
            CompiledFile compiledFile;
            if (TryGetCompiledFile(fullPath, out compiledFile))
            {
                Utils.Log(String.Format("{0}: {1}", ++_cacheHitCount, sourceUnit.Path), "LOAD_CACHED");

                return(compiledFile.CompiledCode);
            }

            Utils.Log(String.Format("{0}: {1}", ++_compiledFileCount, sourceUnit.Path), "LOAD_COMPILED");
#endif

            RubyCompilerOptions options = new RubyCompilerOptions(_context.RubyOptions)
            {
                FactoryKind = (flags & LoadFlags.LoadIsolated) != 0 ? TopScopeFactoryKind.WrappedFile : TopScopeFactoryKind.File
            };

            ScriptCode compiledCode = sourceUnit.Compile(options, _context.RuntimeErrorSink);

#if FEATURE_FILESYSTEM
            AddCompiledFile(fullPath, compiledCode);
#endif
            return(compiledCode);
        }
Пример #6
0
        public virtual TEntity GetEntity <TEntity>(object primaryKeyValue, LoadFlags flags = LoadFlags.Default) where TEntity : class
        {
            Util.Check(primaryKeyValue != null, "Session.GetEntity<{0}>(): primary key may not be null.", typeof(TEntity));
            var entityInfo = GetEntityInfo(typeof(TEntity));

            Util.Check(entityInfo.Kind != EntityKind.View, "Cannot use session.GetEntity<TEntity>(PK) method for views. Entity: {0}.", typeof(TEntity));
            //Check if it is an entity key object; if not, it is a "value" (or values) of the key
            var       pkType = primaryKeyValue.GetType();
            EntityKey pk;

            if (pkType == typeof(EntityKey))
            {
                pk = (EntityKey)primaryKeyValue;
            }
            else
            {
                //try array of objects; if not, it is a single value, turn it into array
                object[] pkValues = pkType == typeof(object[]) ? (object[])primaryKeyValue : new object[] { primaryKeyValue };
                pk = EntityKey.CreateSafe(entityInfo.PrimaryKey, pkValues);
            }
            var rec = GetRecord(pk, flags);

            if (rec != null)
            {
                return((TEntity)(object)rec.EntityInstance);
            }
            return(default(TEntity));
        }
Пример #7
0
        ///////////////////////////////////////////////////////////////////////

        public TclBuild(
            FindFlags findFlags,
            LoadFlags loadFlags,
            object findData,
            string fileName,
            Priority priority,
            Sequence sequence,
            OperatingSystemId operatingSystemId,
            Version patchLevel,
            Tcl_ReleaseLevel releaseLevel,
            ushort magic,
            bool threaded,
            bool debug
            )
        {
            this.findFlags         = findFlags;
            this.loadFlags         = loadFlags;
            this.findData          = findData;
            this.fileName          = fileName;
            this.priority          = priority;
            this.sequence          = sequence;
            this.operatingSystemId = operatingSystemId;
            this.patchLevel        = patchLevel;
            this.releaseLevel      = releaseLevel;
            this.magic             = magic;
            this.threaded          = threaded;
            this.debug             = debug;

            //
            // NOTE: The version may only contain the major and minor parts.
            //
            this.version = GlobalState.GetTwoPartVersion(patchLevel);
        }
        /// <summary>
        /// Method to create an object from a set of object attributes.
        /// </summary>
        /// <param name="obj_attributes">The object attributes to create/open from.</param>
        /// <returns>The newly created object.</returns>
        protected override object CreateObject(ObjectAttributes obj_attributes)
        {
            string key_path = Win32Path ? NtKeyUtils.Win32KeyNameToNt(KeyPath) : KeyPath;

            using (ObjectAttributes name = new ObjectAttributes(key_path, AttributeFlags.CaseInsensitive))
            {
                if (!LoadFlags.HasFlag(LoadKeyFlags.AppKey))
                {
                    using (NtToken token = NtToken.OpenProcessToken())
                    {
                        TokenPrivilege priv = token.GetPrivilege(TokenPrivilegeValue.SeRestorePrivilege);
                        if (priv == null || (priv.Attributes & PrivilegeAttributes.Enabled) == 0)
                        {
                            WriteWarning("Loading a non-app hive should require SeRestorePrivilege");
                        }
                    }
                }
                else
                {
                    if (!KeyPath.StartsWith(@"\Registry\A\", System.StringComparison.OrdinalIgnoreCase))
                    {
                        WriteWarning(@"Loading app hive outside of \Registry\A\ will fail on an up to date system.");
                    }
                }

                if (NoOpen)
                {
                    NtKey.LoadKeyNoOpen(name, obj_attributes, LoadFlags, TrustKey, Event, Token);
                    return(null);
                }
                return(NtKey.LoadKey(name, obj_attributes, LoadFlags, Access, TrustKey, Event, Token));
            }
        }
Пример #9
0
 /// <summary>
 /// Loads a library with flags to use with dlopen. Uses <see cref="LoadFlags"/> for the flags
 ///
 /// Uses NATIVE_DLL_SEARCH_DIRECTORIES and then ld.so for library paths
 /// </summary>
 /// <param name="library">Full name of the library</param>
 /// <param name="flags">See 'man dlopen' for more information.</param>
 public static void Load(string library, LoadFlags flags)
 {
     var paths = (string)AppContext.GetData("NATIVE_DLL_SEARCH_DIRECTORIES");
     foreach (var path in paths.Split(':'))
     {
         if (dlopen(Path.Combine(path, library), flags) != IntPtr.Zero)
             break;
     }
 }
Пример #10
0
        private bool AlreadyLoaded(string /*!*/ path, string fullPath, LoadFlags flags, string[] /*!*/ sourceFileExtensions)
        {
            Debug.Assert(fullPath == null || RubyUtils.GetExtension(path) == RubyUtils.GetExtension(fullPath));

            IEnumerable <string> appendExtensions = (flags & LoadFlags.AppendExtensions) != 0 && RubyUtils.GetExtension(path).Length == 0 ?
                                                    sourceFileExtensions.Concat(_LibraryExtensions) : null;

            return((flags & LoadFlags.LoadOnce) != 0 && IsFileLoaded(path, fullPath, appendExtensions));
        }
Пример #11
0
        public void LoadChar(uint c, LoadFlags flags)
        {
            var err = FreeTypeNative.FT_Load_Char(reference, c, (int)flags);

            if (err != 0)
            {
                throw FreeTypeException.Except(err);
            }
        }
Пример #12
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="glyph">Char index <see cref="TryCharIndex"/></param>
        /// <param name="flags"></param>
        /// <exception cref="FreeTypeException"></exception>
        public void LoadGlyph(uint glyph, LoadFlags flags)
        {
            var err = FreeTypeNative.FT_Load_Glyph(reference, glyph, (int)flags);

            if (err != 0)
            {
                throw FreeTypeException.Except(err);
            }
        }
Пример #13
0
        public void Go(string url, LoadFlags flags)
        {
            if (navigation == null)
            {
                return;
            }

            control.Reset();
            navigation.loadURI(url, (uint)flags, null, null, null);
        }
Пример #14
0
 public FT_Error LoadGlyph(uint glyph_index, LoadFlags flags, LoadTarget target)
 {
     if (Form == LongForm.Long4)
     {
         return(FT_Load_Glyph_4(mHandle, glyph_index, ((Int32)flags | (Int32)target)));
     }
     else
     {
         return(FT_Load_Glyph_8(mHandle, glyph_index, ((Int32)flags | (Int32)target)));
     }
 }
Пример #15
0
        /// <summary>
        /// Overload for loading glyphs that can't be expressed as a char literal like emojis.
        /// Grabs the first 4 bytes in the string
        /// </summary>
        /// <param name="glyph"></param>
        /// <param name="flags"></param>
        /// <returns>bool indicating whether the glyph exists in this face</returns>
        public bool LoadGlyph(string c, LoadFlags flags)
        {
            Encoding.UTF32.GetBytes(c, 0, 2, charCopy, 0);
            var glyphCode = BitConverter.ToUInt32(charCopy, 0);

            if (TryCharIndex(glyphCode, out var index))
            {
                LoadGlyph(index, flags);
                return(true);
            }

            return(false);
        }
Пример #16
0
        public static void LoadAllFromBspStream(BspFile bsp, LoadFlags flags, Stream stream)
        {
            if (bsp == null)
            {
                throw new ArgumentNullException(nameof(bsp), "Target BSP is null.");
            }

            if (stream == null)
            {
                throw new ArgumentNullException(nameof(stream));
            }

            var reader = new BinaryReader(stream);


            var startPos = stream.Position;

            //4 bytes = 1 uint
            uint version = reader.ReadUInt32();

            stream.Position = startPos;


            switch (version)
            {
            case (uint)BspVersion.Quake1:
            {
                throw new BspVersionNotSupportedException(version, "Quake 1");
            }

            case (uint)BspVersion.GoldSource:
            {
                GoldSource.Bsp.LoadAllFromBspStream(bsp, flags, stream);
            }
            break;

            case (uint)BspVersion.ValveBSP:
            {
                throw new BspVersionNotSupportedException(version, "ValveBSP (Source engine)");
            }

            case (uint)BspVersion.RespawnBSP:
            {
                throw new BspVersionNotSupportedException(version, "rBSP (Titanfall)");
            }

            default:
                throw new BspVersionNotSupportedException(version);
            }
        }
Пример #17
0
 /// <summary>Finds the type with the specified name.</summary>
 /// <param name="name">The name of the type (this can be a full type name or a full qualified name with assembly information).</param>
 /// <param name="mode">The loader mode.</param>
 /// <returns>Returns the first matching type.</returns>
 /// <exception cref="System.TypeLoadException">when type cannot be loaded.</exception>
 public static Type FindType(string name, LoadFlags mode = 0)
 {
     if (name.Contains(','))
     {
         var typeName     = name.BeforeFirst(',').Trim();
         var assemblyName = name.AfterFirst(',').Trim();
         var assembly     =
             mode.HasFlag(LoadFlags.LoadAssemblies) ?
             Assembly.Load(assemblyName) ?? throw new TypeLoadException($"Could not load assembly {assemblyName}") :
                   FindAssembly(assemblyName, true);
         return(assembly.GetType(typeName, true, false));
     }
     return(FindType(name, null, mode));
 }
Пример #18
0
        ///////////////////////////////////////////////////////////////////////

#if NATIVE && TCL
        public static bool HasFlags(
            LoadFlags flags,
            LoadFlags hasFlags,
            bool all
            )
        {
            if (all)
            {
                return((flags & hasFlags) == hasFlags);
            }
            else
            {
                return((flags & hasFlags) != LoadFlags.None);
            }
        }
Пример #19
0
        public static void LoadAllFromFile(BspFile bsp, LoadFlags flags, string path)
        {
            if (bsp == null)
            {
                throw new ArgumentNullException(nameof(bsp), "Target BSP is null.");
            }

            if (!File.Exists(path))
            {
                throw new FileNotFoundException("BSP file not found", path);
            }

            using (var stream = File.Open(path, FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                LoadAllFromBspStream(bsp, flags, stream);
            }
        }
Пример #20
0
        /// <summary>
        /// A variant of <see cref="ImageCache.Lookup"/> that uses a <see cref="Scaler"/> to specify the face ID and its
        /// size.
        /// </summary>
        /// <remarks><para>
        /// The returned glyph is owned and managed by the glyph image cache. Never try to transform or discard it
        /// manually! You can however create a copy with <see cref="Glyph.Copy"/> and modify the new one.
        /// </para><para>
        /// If ‘node’ is not NULL, it receives the address of the cache node containing the glyph image,
        /// after increasing its reference count. This ensures that the node (as well as the <see cref="Glyph"/>) will
        /// always be kept in the cache until you call <see cref="Node.Unref"/> to ‘release’ it.
        /// </para><para>
        /// If ‘node’ is NULL, the cache node is left unchanged, which means that the <see cref="Glyph"/>
        /// could be flushed out of the cache on the next call to one of the caching sub-system APIs. Don't assume that
        /// it is persistent!
        /// </para><para>
        /// Calls to <see cref="Face.SetCharSize"/> and friends have no effect on cached glyphs; you should always use
        /// the FreeType cache API instead.
        /// </para></remarks>
        /// <param name="scaler">A pointer to a scaler descriptor.</param>
        /// <param name="loadFlags">The corresponding load flags.</param>
        /// <param name="gIndex">The glyph index to retrieve.</param>
        /// <param name="node">
        /// Used to return the address of of the corresponding cache node after incrementing its reference count (see
        /// note below).
        /// </param>
        /// <returns>The corresponding <see cref="Glyph"/> object. 0 in case of failure.</returns>
        public Glyph LookupScaler(Scaler scaler, LoadFlags loadFlags, uint gIndex, out Node node)
        {
            if (parentManager.IsDisposed)
            {
                throw new ObjectDisposedException("Reference", "Cannot access a disposed object.");
            }

            Error err = FT.FTC_ImageCache_LookupScaler(Reference, scaler.Reference, loadFlags, gIndex, out var glyphRef, out var nodeRef);

            if (err != Error.Ok)
            {
                throw new FreeTypeException(err);
            }

            node = new Node(nodeRef);
            return(new Glyph(glyphRef, null));
        }
Пример #21
0
        public SBit LookupScaler(Scaler scaler, LoadFlags loadFlags, uint gIndex, out Node node)
        {
            if (parentManager.IsDisposed)
            {
                throw new ObjectDisposedException("Reference", "Cannot access a disposed object.");
            }

            IntPtr sbitRef, nodeRef;
            Error  err = FT.FTC_SBitCache_LookupScaler(Reference, scaler.Reference, loadFlags, gIndex, out sbitRef, out nodeRef);

            if (err != Error.Ok)
            {
                throw new FreeTypeException(err);
            }

            node = new Node(nodeRef);
            return(new SBit(sbitRef));
        }
Пример #22
0
        public void Load(string s, out LoadFlags flags)
        {
            flags = LoadFlags.None;
            this.FreezeAutocalc  = true;
            this._tempLoadObject = JObject.Parse(s);
            int saveVersion = this.LookupSaveVersion();

            this.State.Clear();
            switch (saveVersion)
            {
            case 1:
            {
                this.LoadV1(s);
                flags = LoadFlags.V2AdaptV1;
                break;
            }

            case 2:
            {
                this.LoadV2(s, ref flags);
                break;
            }

            default:
                throw new NotSupportedException($"The specified save file version can't be loaded - no format converter exists for version { saveVersion }.");
            }

            AppEvents.InvokeLoad(ref s);

            //HACK modifiers fix
            this.State.General.StatStr -= this.State.General.ModifiersStr.Sum(m => m.Value);
            this.State.General.StatDex -= this.State.General.ModifiersDex.Sum(m => m.Value);
            this.State.General.StatCon -= this.State.General.ModifiersCon.Sum(m => m.Value);
            this.State.General.StatCha -= this.State.General.ModifiersCha.Sum(m => m.Value);
            this.State.General.StatWis -= this.State.General.ModifiersWis.Sum(m => m.Value);
            this.State.General.StatInt -= this.State.General.ModifiersInt.Sum(m => m.Value);
            this.FreezeAutocalc         = false;
            this._ignoreLastSaveFile    = false;
            if (!flags.HasFlag(LoadFlags.KeepLoadObject))
            {
                this._tempLoadObject = null;
            }
        }
Пример #23
0
 public virtual TEntity GetEntity <TEntity>(object primaryKeyValue, LoadFlags flags = LoadFlags.Default) where TEntity : class
 {
     try {
         Util.Check(primaryKeyValue != null, "Session.GetEntity<{0}>(): primary key may not be null.", typeof(TEntity));
         var entityInfo = GetEntityInfo(typeof(TEntity));
         Util.Check(entityInfo.Kind != EntityKind.View, "Cannot use session.GetEntity<TEntity>(PK) method for views. Entity: {0}.", typeof(TEntity));
         //Check if it is an entity key object; if not, it is a "value" (or values) of the key
         var       pkType = primaryKeyValue.GetType();
         EntityKey pk     = entityInfo.CreatePrimaryKeyInstance(primaryKeyValue);
         var       rec    = GetRecord(pk, flags);
         if (rec != null)
         {
             return((TEntity)(object)rec.EntityInstance);
         }
         return(default(TEntity));
     } catch (Exception ex) {
         this._appEvents.OnError(this.Context, ex);
         throw;
     }
 }
Пример #24
0
 private void FileLoaded(MutableString/*!*/ path, LoadFlags flags) {
     if ((flags & LoadFlags.LoadOnce) != 0) {
         AddLoadedFile(path);
     }
 }
Пример #25
0
        private IEnumerable<MutableString>/*!*/ GetPathsToTestLoaded(string/*!*/ path, string fullPath, LoadFlags flags, string[]/*!*/ sourceFileExtensions) {
            List<MutableString> paths = new List<MutableString>();
            paths.Add(_context.EncodePath(path));

            if (fullPath != null) {
                paths.Add(_context.EncodePath(path));
            }

            if ((flags & LoadFlags.AppendExtensions) != 0 && RubyUtils.GetExtension(path).Length == 0) {
                foreach (var extension in sourceFileExtensions) {
                    paths.Add(_context.EncodePath(path + extension));
                }
                foreach (var extension in _LibraryExtensions) {
                    paths.Add(_context.EncodePath(path + extension));
                }
            }

            return paths;
        }
Пример #26
0
 public bool LoadFile(Scope globalScope, object self, MutableString/*!*/ path, LoadFlags flags) {
     object loaded;
     return LoadFile(globalScope, self, path, flags, out loaded);
 }
Пример #27
0
        private void ExecuteRubySourceUnit(SourceUnit/*!*/ sourceUnit, Scope/*!*/ globalScope, LoadFlags flags) {
            Assert.NotNull(sourceUnit, globalScope);
            
            // TODO: check file timestamp
            string fullPath = Platform.GetFullPath(sourceUnit.Path);
            CompiledFile compiledFile;
            if (TryGetCompiledFile(fullPath, out compiledFile)) {
                Utils.Log(String.Format("{0}: {1}", ++_cacheHitCount, sourceUnit.Path), "LOAD_CACHED");
                compiledFile.CompiledCode.Run(globalScope);
            } else {
                Utils.Log(String.Format("{0}: {1}", ++_compiledFileCount, sourceUnit.Path), "LOAD_COMPILED");

                RubyCompilerOptions options = new RubyCompilerOptions(_context.RubyOptions) {
                    IsIncluded = true,
                    IsWrapped = (flags & LoadFlags.LoadIsolated) != 0,
                };

                long ts1 = Stopwatch.GetTimestamp();
                ScriptCode compiledCode = sourceUnit.Compile(options, _context.RuntimeErrorSink);
                long ts2 = Stopwatch.GetTimestamp();
                Interlocked.Add(ref _ScriptCodeGenerationTimeTicks, ts2 - ts1);

                AddCompiledFile(fullPath, compiledCode);

                CompileAndRun(globalScope, compiledCode, _context.Options.InterpretedMode);
            }
        }
Пример #28
0
        private ScriptCode/*!*/ CompileRubySource(SourceUnit/*!*/ sourceUnit, LoadFlags flags) {
            Assert.NotNull(sourceUnit);
            
            // TODO: check file timestamp
            string fullPath = Platform.GetFullPath(sourceUnit.Path);

#if FEATURE_FILESYSTEM
            CompiledFile compiledFile;
            if (TryGetCompiledFile(fullPath, out compiledFile)) {
                Utils.Log(String.Format("{0}: {1}", ++_cacheHitCount, sourceUnit.Path), "LOAD_CACHED");

                return compiledFile.CompiledCode;
            } 

            Utils.Log(String.Format("{0}: {1}", ++_compiledFileCount, sourceUnit.Path), "LOAD_COMPILED");
#endif

            RubyCompilerOptions options = new RubyCompilerOptions(_context.RubyOptions) {
                FactoryKind = (flags & LoadFlags.LoadIsolated) != 0 ? TopScopeFactoryKind.WrappedFile : TopScopeFactoryKind.File
            };

            ScriptCode compiledCode = sourceUnit.Compile(options, _context.RuntimeErrorSink);

#if FEATURE_FILESYSTEM
            AddCompiledFile(fullPath, compiledCode);
#endif
            return compiledCode;
        }
Пример #29
0
 internal static extern Error FT_Get_Advance(IntPtr face, uint gIndex, LoadFlags load_flags, out IntPtr padvance);
Пример #30
0
 internal static extern Error FTC_ImageCache_LookupScaler(IntPtr cache, IntPtr scaler, LoadFlags load_flags, uint gindex, out IntPtr aglyph, out IntPtr anode);
Пример #31
0
		public static extern int gambatte_load(IntPtr core, byte[] romdata, uint length, long now, LoadFlags flags);
Пример #32
0
        public Fixed16Dot16 GetAdvance(uint glyphIndex, LoadFlags flags)
        {
            IntPtr padvance;
            Error err = FT.FT_Get_Advance(Reference, glyphIndex, flags, out padvance);

            if (err != Error.Ok)
                throw new FreeTypeException(err);

            return Fixed16Dot16.FromRawValue((int)padvance);
        }
Пример #33
0
        public unsafe Fixed16Dot16[] GetAdvances(uint start, uint count, LoadFlags flags)
        {
            IntPtr advPtr;
            Error err = FT.FT_Get_Advances(Reference, start, count, flags, out advPtr);

            if (err != Error.Ok)
                throw new FreeTypeException(err);

            //create a new array and copy the data from the pointer over
            Fixed16Dot16[] advances = new Fixed16Dot16[count];
            IntPtr* ptr = (IntPtr*)advPtr;

            for (int i = 0; i < count; i++)
                advances[i] = Fixed16Dot16.FromRawValue((int)ptr[i]);

            return advances;
        }
Пример #34
0
        private ScriptCode/*!*/ CompileRubySource(SourceUnit/*!*/ sourceUnit, LoadFlags flags) {
            Assert.NotNull(sourceUnit);
            
            // TODO: check file timestamp
            string fullPath = Platform.GetFullPath(sourceUnit.Path);
            CompiledFile compiledFile;
            if (TryGetCompiledFile(fullPath, out compiledFile)) {
                Utils.Log(String.Format("{0}: {1}", ++_cacheHitCount, sourceUnit.Path), "LOAD_CACHED");

                return compiledFile.CompiledCode;
            } else {
                Utils.Log(String.Format("{0}: {1}", ++_compiledFileCount, sourceUnit.Path), "LOAD_COMPILED");

                RubyCompilerOptions options = new RubyCompilerOptions(_context.RubyOptions) {
                    FactoryKind = (flags & LoadFlags.LoadIsolated) != 0 ? TopScopeFactoryKind.WrappedFile : TopScopeFactoryKind.File
                };

                long ts1 = Stopwatch.GetTimestamp();
                ScriptCode compiledCode = sourceUnit.Compile(options, _context.RuntimeErrorSink);
                long ts2 = Stopwatch.GetTimestamp();
                Interlocked.Add(ref _ScriptCodeGenerationTimeTicks, ts2 - ts1);

                AddCompiledFile(fullPath, compiledCode);

                return compiledCode;
            }
        }
Пример #35
0
        private bool LoadFromPath(Scope globalScope, object self, string/*!*/ path, LoadFlags flags, out object loaded) {
            Assert.NotNull(path);

            string[] sourceFileExtensions;
            if ((flags & LoadFlags.AnyLanguage) != 0) {
                sourceFileExtensions = DomainManager.Configuration.GetFileExtensions();
            } else {
                sourceFileExtensions = DomainManager.Configuration.GetFileExtensions(_context);
            }

            ResolvedFile file = FindFile(path, (flags & LoadFlags.AppendExtensions) != 0, sourceFileExtensions);
            if (file == null) {
                throw RubyExceptions.CreateLoadError(String.Format("no such file to load -- {0}", path));
            }

            MutableString pathWithExtension = _context.EncodePath(path);
            if (file.AppendedExtension != null) {
                pathWithExtension.Append(file.AppendedExtension);
            }

            if (AlreadyLoaded(pathWithExtension, flags) || _unfinishedFiles.Contains(pathWithExtension.ToString())) {
                if ((flags & LoadFlags.ResolveLoaded) != 0) {
                    var fullPath = Platform.GetFullPath(file.Path);
                    if (file.SourceUnit != null) {
                        Scope loadedScope;
                        if (!LoadedScripts.TryGetValue(fullPath, out loadedScope)) {
                            throw RubyExceptions.CreateLoadError(String.Format("no such file to load -- {0}", file.Path));
                        }
                        loaded = loadedScope;
                    } else {
                        loaded = Platform.LoadAssemblyFromPath(fullPath);
                    }
                } else {
                    loaded = null;
                }
                return false;
            }

            try {
                // save path as is, no canonicalization nor combination with an extension or directory:
                _unfinishedFiles.Push(pathWithExtension.ToString());

                if (file.SourceUnit != null) {
                    AddScriptLines(file.SourceUnit);

                    ScriptCode compiledCode;
                    if (file.SourceUnit.LanguageContext == _context) {
                        compiledCode = CompileRubySource(file.SourceUnit, flags);
                    } else {
                        compiledCode = file.SourceUnit.Compile();
                    }
                    loaded = Execute(globalScope, compiledCode);
                } else {
                    Debug.Assert(file.Path != null);
                    try {
                        Assembly assembly = Platform.LoadAssemblyFromPath(Platform.GetFullPath(file.Path));
                        DomainManager.LoadAssembly(assembly);
                        loaded = assembly;
                    } catch (Exception e) {
                        throw RubyExceptions.CreateLoadError(e);
                    }
                }

                FileLoaded(pathWithExtension, flags);
            } finally {
                _unfinishedFiles.Pop();
            }

            return true;
        }
Пример #36
0
        /// <summary>
        /// Returns <b>true</b> if a Ruby file is successfully loaded, <b>false</b> if it is already loaded.
        /// </summary>
        /// <param name="globalScope">
        /// A scope against which the file should be executed or null to create a new scope.
        /// </param>
        /// <returns>True if the file was loaded/executed by this call.</returns>
        public bool LoadFile(Scope globalScope, object self, MutableString/*!*/ path, LoadFlags flags, out object loaded) {
            Assert.NotNull(path);

            string assemblyName, typeName;

            string strPath = path.ConvertToString();
            if (TryParseAssemblyName(strPath, out typeName, out assemblyName)) {

                if (AlreadyLoaded(path, flags)) {
                    loaded = ((flags & LoadFlags.ResolveLoaded) != 0) ? GetAssembly(assemblyName, true, false) : null;
                    return false;
                }

                Assembly assembly = LoadAssembly(assemblyName, typeName, false, false);
                if (assembly != null) {
                    FileLoaded(path, flags);
                    loaded = assembly;
                    return true;
                }
            }

            return LoadFromPath(globalScope, self, strPath, flags, out loaded);
        }
Пример #37
0
 private bool AlreadyLoaded(string/*!*/ path, string fullPath, LoadFlags flags, string[]/*!*/ sourceFileExtensions) {
     Debug.Assert(fullPath == null || RubyUtils.GetExtension(path) == RubyUtils.GetExtension(fullPath));
     return (flags & LoadFlags.LoadOnce) != 0 && AnyFileLoaded(GetPathsToTestLoaded(path, fullPath, flags, sourceFileExtensions));
 }
Пример #38
0
        public void LoadChar(uint charCode, LoadFlags flags, LoadTarget target)
        {
            if (disposed)
                throw new ObjectDisposedException("face", "Cannot access a disposed object.");

            Error err = FT.FT_Load_Char(Reference, charCode, (int)flags | (int)target);

            if (err != Error.Ok)
                throw new FreeTypeException(err);
        }
Пример #39
0
 private bool AlreadyLoaded(string/*!*/ path, string fullPath, LoadFlags flags) {
     return AlreadyLoaded(path, fullPath, flags, ArrayUtils.EmptyStrings);
 }
Пример #40
0
        public int GetAdvance(uint glyphIndex, LoadFlags flags)
        {
            int padvance;
            Error err = FT.FT_Get_Advance(Reference, glyphIndex, flags, out padvance);

            if (err != Error.Ok)
                throw new FreeTypeException(err);

            return padvance;
        }
Пример #41
0
			public static extern IntPtr LoadLibraryEx (string lpFileName, IntPtr hFile, LoadFlags dwFlags);
Пример #42
0
 private static extern IntPtr dlopen(string library, LoadFlags flags);
Пример #43
0
 public static extern int gambatte_load(IntPtr core, byte[] romdata, uint length, long now, LoadFlags flags);
Пример #44
0
        /// <summary>
        /// Returns <b>true</b> if a Ruby file is successfully loaded, <b>false</b> if it is already loaded.
        /// </summary>
        public bool LoadFile(Scope/*!*/ globalScope, object self, MutableString/*!*/ path, LoadFlags flags) {
            Assert.NotNull(globalScope, path);

            string assemblyName, typeName;

            string strPath = path.ConvertToString();
            if (TryParseAssemblyName(strPath, out typeName, out assemblyName)) {

                if (AlreadyLoaded(path, flags)) {
                    return false;
                }

                if (LoadAssembly(assemblyName, typeName, false)) {
                    FileLoaded(path, flags);
                    return true;
                }
            }

            return LoadFromPath(globalScope, self, strPath, flags);
        }
Пример #45
0
 internal static extern Error FT_Get_Advances(IntPtr face, uint start, uint count, LoadFlags load_flags, out IntPtr padvance);
Пример #46
0
 /// <summary>
 /// Return true if any of the files has alraedy been loaded.
 /// </summary>
 private bool AlreadyLoaded(string/*!*/ path, IEnumerable<ResolvedFile>/*!*/ files, LoadFlags flags) {
     return (flags & LoadFlags.LoadOnce) != 0 && AnyFileLoaded(
         new[] { _context.EncodePath(path) }.Concat(files.Select((file) => _context.EncodePath(file.Path)))
     );
 }
Пример #47
0
 internal static extern Error FTC_SBitCache_LookupScaler(IntPtr cache, IntPtr scaler, LoadFlags load_flags, uint gindex, out IntPtr sbit, out IntPtr anode);
Пример #48
0
 internal static extern Error FT_Get_Advance(IntPtr face, uint gIndex, LoadFlags load_flags, out int padvance);
Пример #49
0
        public void LoadGlyph(uint glyphIndex, LoadFlags flags, LoadTarget target)
        {
            if (disposed)
                throw new ObjectDisposedException("face", "Cannot access a disposed object.");

            Error err = FT.FT_Load_Glyph(Reference, glyphIndex, (int)flags | (int)target);

            if (err != Error.Ok)
                throw new FreeTypeException(err);
        }
Пример #50
0
 internal static extern Error FT_Get_Advances(IntPtr face, uint start, uint count, LoadFlags load_flags, out IntPtr padvance);
Пример #51
0
        public unsafe int[] GetAdvances(uint start, uint count, LoadFlags flags)
        {
            IntPtr advPtr;
            Error err = FT.FT_Get_Advances(Reference, start, count, flags, out advPtr);

            if (err != Error.Ok)
                throw new FreeTypeException(err);

            //create a new array and copy the data from the pointer over
            int[] advances = new int[count];
            int* ptr = (int*)advPtr;

            for (int i = 0; i < count; i++)
                advances[i] = ptr[i];

            return advances;
        }
Пример #52
0
 internal static extern Error FTC_ImageCache_LookupScaler(IntPtr cache, IntPtr scaler, LoadFlags load_flags, uint gindex, out IntPtr aglyph, out IntPtr anode);
			public static IntPtr LoadLibraryEx (string lpFileName, IntPtr hFile, LoadFlags dwFlags)
			{
				throw new System.NotImplementedException();
			}
Пример #54
0
 internal static extern Error FTC_SBitCache_LookupScaler(IntPtr cache, IntPtr scaler, LoadFlags load_flags, uint gindex, out IntPtr sbit, out IntPtr anode);
Пример #55
0
        private bool LoadFromPath(Scope/*!*/ globalScope, object self, string/*!*/ path, LoadFlags flags) {
            Assert.NotNull(globalScope, path);

            ResolvedFile file = FindFile(globalScope, path, (flags & LoadFlags.AppendExtensions) != 0);
            if (file == null) {
                throw new LoadError(String.Format("no such file to load -- {0}", path));
            }

            MutableString pathWithExtension = MutableString.Create(path);
            if (file.AppendedExtension != null) {
                pathWithExtension.Append(file.AppendedExtension);
            }

            if (AlreadyLoaded(pathWithExtension, flags) || _unfinishedFiles.Contains(pathWithExtension.ToString())) {
                return false;
            }

            try {
                // save path as is, no canonicalization nor combination with an extension or directory:
                _unfinishedFiles.Push(pathWithExtension.ToString());

                if (file.SourceUnit != null) {

                    RubyContext rubySource = file.SourceUnit.LanguageContext as RubyContext;
                    if (rubySource != null) {
                        ExecuteRubySourceUnit(file.SourceUnit, globalScope, flags);
                    } else {
                        file.SourceUnit.Execute();
                    }
                } else {
                    Debug.Assert(file.Path != null);
                    try {
                        Assembly asm = Platform.LoadAssemblyFromPath(Platform.GetFullPath(file.Path));
                        DomainManager.LoadAssembly(asm);
                    } catch (Exception e) {
                        throw new LoadError(e.Message, e);
                    }
                }

                FileLoaded(pathWithExtension, flags);
            } finally {
                _unfinishedFiles.Pop();
            }

            return true;
        }
 internal XmlRawWriter LoadFromWriter(LoadFlags flags, string baseUri)
 {
     return new XPathDocumentBuilder(this, null, baseUri, flags);
 }
Пример #57
0
 private bool AlreadyLoaded(MutableString/*!*/ path, LoadFlags flags) {
     return (flags & LoadFlags.LoadOnce) != 0 && IsFileLoaded(path);
 }
Пример #58
0
        public Glyph LookupScaler(Scaler scaler, LoadFlags loadFlags, uint gIndex, out Node node)
        {
            if (parentManager.IsDisposed)
                throw new ObjectDisposedException("Reference", "Cannot access a disposed object.");

            IntPtr glyphRef, nodeRef;
            Error err = FT.FTC_ImageCache_LookupScaler(Reference, scaler.Reference, loadFlags, gIndex, out glyphRef, out nodeRef);

            if (err != Error.Ok)
                throw new FreeTypeException(err);

            node = new Node(nodeRef);
            return new Glyph(glyphRef, null);
        }
Пример #59
0
		public abstract bool Init(ref LoadData loadData, ControllerType[] controllerSettings, LoadFlags loadFlags);
Пример #60
0
		public DubProject LoadProject(string file, Solution parentSolution, IProgressMonitor monitor, LoadFlags flags = LoadFlags.LoadReferences, DubProject superProject = null)
		{
			DubProject prj;

			if (FilesBeingLoaded.TryGetValue(file, out prj))
				return prj;

			using (new FilesBeingLoadedCleanser(file))
			{
				monitor.BeginTask("Load dub project '" + file + "'", 1);
				try
				{
					prj = supportedDubFileFormats.First((i) => i.CanLoad(file)).Load(file, superProject, parentSolution);
				}
				catch (Exception ex)
				{
					monitor.ReportError("Couldn't load dub package \"" + file + "\"", ex);
				}
				finally
				{
					monitor.EndTask();
				}

				if (flags.HasFlag(LoadFlags.LoadReferences))
					LoadSubProjects(prj, monitor);
			}

			return prj;
		}