Skip to content

Commit

Permalink
Revert usage of createIOType, see #188
Browse files Browse the repository at this point in the history
  • Loading branch information
samreid committed Sep 11, 2020
1 parent 1badc04 commit 9bde4c8
Showing 1 changed file with 0 additions and 78 deletions.
78 changes: 0 additions & 78 deletions js/types/ObjectIO.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,84 +285,6 @@ ObjectIO.validator = {

ObjectIO.validateIOType( ObjectIO );

/**
* Function that creates an IO Type associated with a core type. Methods are forwarded to the core type.
* @param {function} coreType, e.g., Bunny
* @param {string} typeName, e.g., BunnyIO
* @param {Object} [options]
* @returns {IOType}
* @public
*/
ObjectIO.createIOType = ( coreType, typeName, options ) => {
assert && assert( typeName.endsWith( PhetioConstants.IO_TYPE_SUFFIX ) || typeName.includes( `${PhetioConstants.IO_TYPE_SUFFIX}<` ), 'IO Type name must end with IO' );
options = merge( {

// The parent IO Type, which will have standard 'class extends' inheritance, and inherit methods, events, etc.
// and be shown as a parent type in Studio + API docs
parentIOType: ObjectIO,

// {string} e.g., "Animal that has a genotype (genetic blueprint) and a phenotype (appearance)."
documentation: `IO Type for ${typeName.substring( 0, typeName.length - 2 )}`,

// {Object} - key/value pairs with methods, see PhetioEngineIO for an example
methods: {},

events: [],
parameterTypes: []
}, options );

class IOType extends options.parentIOType {

/**
* @param {PhetioObject} phetioObject
* @returns {Object}
* @public
* @override
*/
static toStateObject( phetioObject ) {
validate( phetioObject, this.validator );
return phetioObject.toStateObject();
}

// @public
static fromStateObject( stateObject ) {
return coreType.fromStateObject( stateObject );
}

/**
* @param {Object} stateObject
* @returns {Object[]}
* @public
* @override
*/
static stateToArgsForConstructor( stateObject ) {
return coreType.stateToArgsForConstructor( stateObject );
}

/**
* Restores coreType state after instantiation.
* @param {PhetioObject} phetioObject
* @param {Object} stateObject
* @public
* @override
*/
static applyState( phetioObject, stateObject ) {
validate( phetioObject, this.validator );
phetioObject.applyState( stateObject );
}
}

IOType.documentation = options.documentation;
IOType.validator = { valueType: coreType };
IOType.typeName = typeName;
IOType.events = options.events;
IOType.parameterTypes = options.parameterTypes;
IOType.methods = options.methods;
ObjectIO.validateIOType( IOType );

return IOType;
};

/**
* Fills in the boilerplate for static fields of an IO Type.
* @param {function} ioType - an IO Type
Expand Down

0 comments on commit 9bde4c8

Please sign in to comment.