Skip to content

Commit

Permalink
Stream type update
Browse files Browse the repository at this point in the history
Removed __Buffer__ and added __Stream__.  __Stream__ is now a type on data structures that indicates they can be wrapped with __Stream__ and thus using in from_input and to_output method calls.
  • Loading branch information
Hyomoto committed Jun 24, 2021
1 parent 1898403 commit 8ff3974
Show file tree
Hide file tree
Showing 37 changed files with 416 additions and 223 deletions.
14 changes: 7 additions & 7 deletions FAST.yyp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions objects/oATSobj/KeyPress_32.gml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ var _total = 0;
}
_total += _timer.elapsed();

while ( _script.__pool__.is_empty() == false ) {
syslog( _script.__pool__.get() );

}
syslog( "ObjectPool size was ", _script.__pool__.size() );

//
syslog( "Scripts GML ", _loop * 100,": ", string_from_time( _total/1000000, "$S.SSSS seconds" ));
2 changes: 2 additions & 0 deletions objects/oATSobj/KeyPress_33.gml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
start += lines;
surface.redraw();
2 changes: 2 additions & 0 deletions objects/oATSobj/KeyPress_34.gml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
start = max( 0, start - lines );
surface.redraw();
2 changes: 2 additions & 0 deletions objects/oATSobj/KeyPress_35.gml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
start = 0;
surface.redraw();
2 changes: 2 additions & 0 deletions objects/oATSobj/KeyPress_36.gml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
start = array_length( list ) - lines;
surface.redraw();
4 changes: 4 additions & 0 deletions objects/oATSobj/oATSobj.yy

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions scripts/FAST_macros/FAST_macros.gml

This file was deleted.

12 changes: 0 additions & 12 deletions scripts/FAST_macros/FAST_macros.yy

This file was deleted.

35 changes: 0 additions & 35 deletions scripts/ListBuffer/ListBuffer.gml

This file was deleted.

12 changes: 0 additions & 12 deletions scripts/ListBuffer/ListBuffer.yy

This file was deleted.

12 changes: 0 additions & 12 deletions scripts/ListBuffer/TextFile.yy

This file was deleted.

10 changes: 8 additions & 2 deletions scripts/ObjectPool/ObjectPool.gml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/// @func ObjectPool
/// @param {method} new A method that returns a new object for this pool.
/// @desc Holds a pool of objects that can be reused.
function ObjectPool( _new = function() { return {}; } ) constructor {
function ObjectPool( _new ) constructor {
/// @param {mixed} value An object
/// @desc Puts an object into the pool and returns it.
/// @returns mixed
Expand All @@ -17,6 +17,12 @@ function ObjectPool( _new = function() { return {}; } ) constructor {
if ( ds_stack_empty( __Pool ) ) { return __New(); }
return ds_stack_pop( __Pool );

}
/// @desc Returns the number of objects in the pool
/// @returns int
static size = function() {
return ds_stack_size( __Pool );

}
/// @desc Returns true if the pool is empty.
/// @returns bool
Expand Down Expand Up @@ -48,7 +54,7 @@ function ObjectPool( _new = function() { return {}; } ) constructor {
return self;

}
__New = _new;
__New = _new == undefined ? function() { return {}; } : _new;
__Pool = ds_stack_create();

}
89 changes: 89 additions & 0 deletions scripts/Queue/Queue.gml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/// @func Queue
/// @desc Am alternative to the built-in queue. It makes use of a simple linked list to provide
/// a fast, cheap, garbage-collected queue.
function Queue() : __Struct__() constructor {
static __pool__ = new ObjectPool();
/// @param {mixed} values... Values to add to the queue
/// @desc Pushes the values to the queue in order.
/// @returns self
static push = function() {
var _i = 0; repeat( argument_count ) {
var _link = __pool__.get();

_link.value = argument[ _i++ ];
_link.next = undefined;

if ( __First == undefined ) {
__First = _link;
__Last = _link;

} else {
__Last.next = _link;

}
__Size += 1;

}
return self;

}
/// @desc Pops the first value added to the queue, or EOQ if it is empty.
/// @returns mixed
static pop = function() {
if ( is_empty() ) { return EOQ; }

var _value = __First.value;

__First = __pool__.put( __First ).next;
__Size -= 1;

return _value;

}
/// @desc Returns the value at the head of the queue, or EOQ if it is empty.
/// @returns mixed
static top = function() {
if ( __Size == 0 ) { return EOQ; }

return __First.value;

}
/// @desc Returns the head of the queue
/// @desc Returns true if the queue is empty.
/// @returns bool
static is_empty = function() {
return size() == 0;

}
/// @desc Returns the number of elements in the queue.
/// @returns int
static size = function() {
return __Size;

}
/// @desc Returns the contents of the stack as a string
static toString = function() {
var _str = "";

var _node = __First; repeat( size() ) {
if ( _str != "" ) { _str += ","; }
_str += string( _node.value );
_node = _node.next;

}
return "[ " + _str + " ]";

}
/// @var {strict} A value that is returned when the queue is empty
static EOQ = {};
/// @var {struct} A pointer to the first node in the queue
__First = undefined;
/// @var {struct} A pointer to the last node in the queue
__Last = undefined;
/// @var {int} The number of nodes in the queue
__Size = 0;

__Type__.add( __Stream__ );
__Type__.add( Queue );

}
6 changes: 3 additions & 3 deletions scripts/ListBuffer/QueueBuffer.yy → scripts/Queue/Queue.yy

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 0 additions & 35 deletions scripts/QueueBuffer/QueueBuffer.gml

This file was deleted.

12 changes: 0 additions & 12 deletions scripts/QueueBuffer/QueueBuffer.yy

This file was deleted.

12 changes: 0 additions & 12 deletions scripts/QueueBuffer/TextFile.yy

This file was deleted.

Loading

0 comments on commit 8ff3974

Please sign in to comment.