Beispiel #1
0
 public ByteBuffer(int initialCapacity, int maxCapacity, ByteBufferAllocator allocator)
 {
     _data          = new byte[initialCapacity];
     _maxCapacity   = maxCapacity > initialCapacity ? maxCapacity : initialCapacity;
     _writePosition = 0;
     _readPosition  = 0;
     _allocator     = allocator;
 }
Beispiel #2
0
        public void Initialize(IFileSystem fileSystem, IScriptRuntimeListener runner, IScriptLogger logger, IO.ByteBufferAllocator byteBufferAllocator, int step = 30)
        {
            if (logger == null)
            {
                throw new NullReferenceException(nameof(logger));
            }
            if (runner == null)
            {
                throw new NullReferenceException(nameof(runner));
            }
            if (fileSystem == null)
            {
                throw new NullReferenceException(nameof(fileSystem));
            }
            var bindAll = typeof(Values).GetMethod("BindAll");

            if (bindAll == null)
            {
                throw new Exception("Generate binding code before run");
            }
            _byteBufferAllocator = byteBufferAllocator;
            _fileSystem          = fileSystem;
            _logger = logger;

            _typeDB = new TypeDB(this, _mainContext);
            var register = new TypeRegister(this, _mainContext);

            register.RegisterType(typeof(ScriptBridge));
            // await Task.Run(() => runner.OnBind(this, register));
            bindAll.Invoke(null, new object[] { register });
            runner.OnBind(this, register);
            TimerManager.Bind(register);
            ScriptContext.Bind(register);
            register.Finish();
            runner.OnComplete(this);
        }