diff options
Diffstat (limited to '1.4.0/dom/codeGen')
115 files changed, 9034 insertions, 0 deletions
diff --git a/1.4.0/dom/codeGen/1.4/gen.php b/1.4.0/dom/codeGen/1.4/gen.php new file mode 100644 index 0000000..3cd8a5d --- /dev/null +++ b/1.4.0/dom/codeGen/1.4/gen.php @@ -0,0 +1,158 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +// COMMAND LINE: bin/php.exe gen.php collada.xsd [minimal] +// Note: must be run from home directory of code generator (i.e. where gen.php lives) + +ini_set("memory_limit", "256M"); + +if ( file_exists( $argv[1] ) ) { $collada_file = $argv[1]; } +else +{ + die( "Can't find COLLADA file '" . $argv[1] . "'\n" ); +} + + +require_once( 'src/SchemaParser.php' ); +require_once( 'om/object-model.php' ); +require_once( 'tpl/template-engine.php' ); + +// Returns either a capitalized or non-capitalized version of the name, thus helping us +// avoid name clashes. For example, say we have an element called 'rgb' and an element +// called 'RGB'. They're both going to map to the name constant 'COLLADA_ELEMENT_RGB'. +// Instead, use COLLADA_ELEMENT_rgb for the 'rgb' element. +function getUniqueName($name, $array) { + $uniqueName = strtoupper($name); + if (array_search($uniqueName, $array) !== FALSE) { + $uniqueName = $name; + } + return $uniqueName; +} + + +if ( preg_match( "/min/i", $argv[2] ) || preg_match( "/min/i", $argv[3] ) ) { + $_globals['full_code'] = false; +} +if ( preg_match( "/cprt/i", $argv[2] ) || preg_match( "/cprt/i", $argv[3] ) ) { + $_globals['copyright'] = true; +} + +$_globals['accessorsAndMutators'] = true; + +$p = new SchemaParser(); +$p->parse( $collada_file ); + + +initGen( $collada_file ); + + +$pop = $p->root_elements[0]; + +//Grab the collada version number +$_globals['constStrings']['COLLADA_VERSION'] = "\"". $pop->getAttribute('version') . "\";\n"; +//Grab the collada namespace +$_globals['constStrings']['COLLADA_NAMESPACE'] = "\"". $pop->getAttribute('xmlns') . "\";\n\n"; + +// Grab simple types and collect meta-data for code-gen +$t_list = $pop->getElementsByType( 'xsSimpleType' ); + + +$typemeta = array(); + +for( $i=0; $i<count( $t_list ); $i++ ) +{ + $local_meta = & $t_list[$i]->generate(); + $typemeta[ $local_meta['type'] ] = & $local_meta; + //print "Type: ". $local_meta['type'] ." created\n"; +} + +function propogateArrayTypes( &$lmeta ) { + global $typemeta; + if ( $lmeta['isArray'] ) { + return; + } + if( isset( $typemeta[$lmeta['base']] ) ) { + propogateArrayTypes( $typemeta[$lmeta['base']] ); + $lmeta['isArray'] = $typemeta[$lmeta['base']]['isArray']; + } + //print $lmeta['type'] ." isArray = ". $lmeta['isArray'] ."\n"; +} +foreach( $typemeta as $k => &$local_meta ) { + propogateArrayTypes( $local_meta ); +} + +//Grab global complex types and make them available for all who need them + +$_globals['complex_types'] = $pop->getElementsByType( 'xsComplexType' ); + +//generate type meta data +//print applyTemplate( 'TYPES_HEADER_FILE', $typemeta ); +//print applyTemplate( 'TYPES_CPP_FILE', $typemeta ); + +$element_context = array(); +$meta = array(); + +print "COMPLEX TYPES\n"; +for( $i=0; $i<count( $_globals['complex_types'] ); $i++ ) +{ + $local_meta = & $_globals['complex_types'][$i]->generate( $element_context, $_globals['global_elements'] ); + $meta[ $local_meta['element_name'] ] = & $local_meta; +} + +//collect element meta-data for code-gen + +//Grab global groups and make them available for all who need them +$_globals['groups'] = $pop->getElementsByType( 'xsGroup' ); +//collect meta-data for code-gen +print "GROUPS\n"; +for( $i=0; $i<count( $_globals['groups'] ); $i++ ) +{ + $local_meta = & $_globals['groups'][$i]->generate( $element_context, $_globals['global_elements'] ); + $meta[ $local_meta['element_name'] ] = & $local_meta; +} + +// Grab global elements and collect meta-data for code-gen +$e_list = $pop->getElementsByType( 'xsElement' ); + +print "ELEMENTS\n"; + +for( $i=0; $i<count( $e_list ); $i++ ) +{ + $local_meta = & $e_list[$i]->generate( $element_context, $_globals['global_elements'] ); + $meta[ $local_meta['element_name'] ] = & $local_meta; +} + +//propogate the substitutableWith lists and attributes inherited by type +foreach( $meta as $k => &$local_meta ) { + if ( $local_meta['substitution_group'] != '' ) { + $meta[$local_meta['substitution_group']]['substitutableWith'][] = $k; + //$meta[$local_meta['substitution_group']]['ref_elements'][] = $k; + //print $local_meta['substitution_group'] ." sub with ". $k ."\n"; + } +} + +$indentNum = 0; +// Generate header files +$includeList = array(); +foreach( $meta as $k => &$local_meta ) +{ + // Generate the dom + print applyTemplate( 'HEADER_FILE', $local_meta ); + print applyTemplate( 'CPP_FILE', $local_meta ); +} + +print applyTemplate( 'TYPES_HEADER_FILE', $typemeta ); +print applyTemplate( 'TYPES_CPP_FILE', $typemeta ); + +print applyTemplate( 'ELEMENTS_FILE', $meta ); +print applyTemplate( 'CONSTANTS_FILE', $_globals['constStrings'] ); +print applyTemplate( 'CONSTANTS_CPP_FILE', $_globals['constStrings'] ); +cleanupGen(); + +?> diff --git a/1.4.0/dom/codeGen/1.4/om/base-types.php b/1.4.0/dom/codeGen/1.4/om/base-types.php new file mode 100644 index 0000000..48fe862 --- /dev/null +++ b/1.4.0/dom/codeGen/1.4/om/base-types.php @@ -0,0 +1,172 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +class _type +{ + var $type = array(); + + function _type() + { + $this->type[] = "MotherOfAllTypes"; + } + + function isOfType( $type ) + { + return( $type == $this->type[ count( $this->type ) - 1 ] ); + } + + function getType() + { + $type = "NULL"; + if ( count( $this->type ) > 0 ) { $type = $this->type[ 0 ]; } + return $type; + } + + function isAncestor( $type ) + { + return in_array( $type, $this->type ); + } +} + +class _typedData extends _type +{ + var $data; + + var $attributeMeta = array(); + var $attributes = array(); + + function _typedData() + { + $this->type[] = "TypedData"; + parent::_type(); + } + + function _addAttribute( $name, $meta ) + { + $this->attributeMeta[ $name ] = $meta; + } + + function setAttribute( $name, $value ) + { + // Make sure we know about the attribute before setting it + if ( isset( $this->attributeMeta[ $name ] ) ) + { + $this->attributes[ $name ] = $value; + } + } + + function getAttribute( $name ) + { + $val = ""; + if ( isset( $this->attributeMeta[ $name ] ) && isset( $this->attributes[ $name ] ) ) { + $val = $this->attributes[ $name ]; + } + return $val; + } + + function & getAttributes() + { + return $this->attributes; + } + + function set( & $buffer ) + { + $this->data = $buffer; + } + + function append( & $buffer ) + { + $this->data .= $buffer; + } + + function get() + { + return $this->data; + } +} + +class _elementSet extends _typedData +{ + var $elementMeta = array(); + var $elements = array(); + + function _elementSet() + { + $this->_addAttribute( 'minOccurs', array( 'type' => 'xs:integer' ) ); + $this->setAttribute( 'minOccurs', '1' ); + $this->_addAttribute( 'maxOccurs', array( 'type' => 'xs:integer' ) ); + $this->setAttribute( 'maxOccurs', '1' ); + + $this->type[] = "ElementSet"; + parent::_typedData(); + } + + function _addElement( $name, $attrs ) + { + $this->elementMeta[ $name ] = $attrs; + } + + function addElement( & $e ) + { + if ( in_array( $e->getType(), array_keys( $this->elementMeta ) ) ) + { + $this->elements[] = & $e; + } else + { + print "Invalid element ". $e->getType() ."in ". $this->getType() ."\n"; + $this->log( "WARN: " . $e->getType() . " not a valid member of " . $this->getType() ); + } + } + + function & getElements() + { + return $this->elements; + } + + function & getElementsByType( $type ) + { + $list = array(); + for( $i=0; $i<count( $this->elements ); $i++ ) + { + if ( $this->elements[$i]->getType() == $type ) + { + $list[] = & $this->elements[$i]; + } + } + return $list; + } + + function setElement( $name, & $value ) + { + $this->elements[ $name ] = $value; + } + + function exists( $name ) + { + return isset( $this->elements[ $name ] ); + } + + function delete( $name ) + { + unset( $this->elements[ $name ] ); + } + + function _delete( $name ) + { + $this->delete( $name ); + unset( $this->elementMeta[ $name ] ); + } + + function getCount() + { + return count( $this->elements ); + } +} + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.4/om/object-model.php b/1.4.0/dom/codeGen/1.4/om/object-model.php new file mode 100644 index 0000000..271c04b --- /dev/null +++ b/1.4.0/dom/codeGen/1.4/om/object-model.php @@ -0,0 +1,43 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +require_once( 'om/base-types.php' ); + +require_once( 'om/xsAll.php' ); +require_once( 'om/xsAnnotation.php' ); +require_once( 'om/xsAny.php' ); +require_once( 'om/xsAttribute.php' ); +require_once( 'om/xsChoice.php' ); +require_once( 'om/xsComplexContent.php' ); +require_once( 'om/xsComplexType.php' ); +require_once( 'om/xsAll.php' ); +require_once( 'om/xsDocumentation.php' ); +require_once( 'om/xsAppinfo.php' ); +require_once( 'om/xsElement.php' ); +require_once( 'om/xsEnumeration.php' ); +require_once( 'om/xsExtension.php' ); +require_once( 'om/xsGroup.php' ); +require_once( 'om/xsList.php' ); +require_once( 'om/xsMaxLength.php' ); +require_once( 'om/xsMaxExclusive.php' ); +require_once( 'om/xsMaxInclusive.php' ); +require_once( 'om/xsMinLength.php' ); +require_once( 'om/xsMinExclusive.php' ); +require_once( 'om/xsMinInclusive.php' ); +require_once( 'om/xsPattern.php' ); +require_once( 'om/xsRestriction.php' ); +require_once( 'om/xsSchema.php' ); +require_once( 'om/xsSequence.php' ); +require_once( 'om/xsSimpleContent.php' ); +require_once( 'om/xsSimpleType.php' ); +require_once( 'om/xsUnion.php' ); +require_once( 'om/xsWhiteSpace.php' ); +require_once( 'om/xsImport.php' ); + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.4/om/xsAll.php b/1.4.0/dom/codeGen/1.4/om/xsAll.php new file mode 100644 index 0000000..bbe1b45 --- /dev/null +++ b/1.4.0/dom/codeGen/1.4/om/xsAll.php @@ -0,0 +1,27 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +class xsAll extends _elementSet +{ + function xsAll() + { + $this->_addElement( 'xsElement', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsAttribute', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + + $this->type[] = "xsAll"; + parent::_elementSet(); + } + + function addAllElement( & $e ) + { + $this->addElement( $e ); + } +} + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.4/om/xsAnnotation.php b/1.4.0/dom/codeGen/1.4/om/xsAnnotation.php new file mode 100644 index 0000000..b6fbd4b --- /dev/null +++ b/1.4.0/dom/codeGen/1.4/om/xsAnnotation.php @@ -0,0 +1,31 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +class xsAnnotation extends _elementSet +{ + function xsAnnotation() + { + $this->_addElement( 'xsDocumentation', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsAppinfo', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + + $this->type[] = "xsAnnotation"; + parent::_elementSet(); + + // Set bounds on number of elements allowable in annotation element + $this->setAttribute( 'minOccurs', '0' ); + $this->setAttribute( 'maxOccurs', 'unbounded' ); + } + + function addAnnotationElement( & $e ) + { + $this->addElement( $e ); + } +} + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.4/om/xsAny.php b/1.4.0/dom/codeGen/1.4/om/xsAny.php new file mode 100644 index 0000000..3a35831 --- /dev/null +++ b/1.4.0/dom/codeGen/1.4/om/xsAny.php @@ -0,0 +1,27 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +class xsAny extends _typedData +{ + function xsAny() + { + $this->_addAttribute( 'namespace', array( 'type' => 'xs:anyURI' ) ); + $this->_addAttribute( 'processContents', array( 'type' => 'xs:string' ) ); + + $this->_addAttribute( 'minOccurs', array( 'type' => 'xs:integer' ) ); + $this->setAttribute( 'minOccurs', '1' ); + $this->_addAttribute( 'maxOccurs', array( 'type' => 'xs:integer' ) ); + $this->setAttribute( 'maxOccurs', '1' ); + + $this->type[] = 'xsAny'; + parent::_typedData(); + } +} + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.4/om/xsAppinfo.php b/1.4.0/dom/codeGen/1.4/om/xsAppinfo.php new file mode 100644 index 0000000..625296b --- /dev/null +++ b/1.4.0/dom/codeGen/1.4/om/xsAppinfo.php @@ -0,0 +1,19 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +class xsAppinfo extends _typedData +{ + function xsAppinfo() + { + $this->type[] = "xsAppinfo"; + parent::_typedData(); + } +} + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.4/om/xsAttribute.php b/1.4.0/dom/codeGen/1.4/om/xsAttribute.php new file mode 100644 index 0000000..f8aa845 --- /dev/null +++ b/1.4.0/dom/codeGen/1.4/om/xsAttribute.php @@ -0,0 +1,27 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +class xsAttribute extends _elementSet +{ + function xsAttribute() + { + $this->_addAttribute( 'name', array( 'type' => 'xs:string' ) ); + $this->_addAttribute( 'type', array( 'type' => 'xs:string' ) ); + $this->_addAttribute( 'use', array( 'type' => 'xs:string' ) ); + $this->_addAttribute( 'default', array( 'type' => 'xs:string' ) ); + $this->_addAttribute( 'ref', array( 'type' => 'xs:string' ) ); + + $this->_addElement( 'xsAnnotation', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + + $this->type[] = 'xsAttribute'; + parent::_typedData(); + } +} + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.4/om/xsChoice.php b/1.4.0/dom/codeGen/1.4/om/xsChoice.php new file mode 100644 index 0000000..9d31c5d --- /dev/null +++ b/1.4.0/dom/codeGen/1.4/om/xsChoice.php @@ -0,0 +1,31 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +class xsChoice extends _elementSet +{ + function xsChoice() + { + $this->_addElement( 'xsElement', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsAttribute', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsChoice', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsSequence', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsGroup', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsAnnotation', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + + $this->type[] = "xsChoice"; + parent::_elementSet(); + } + + function addChoiceElement( & $e ) + { + $this->addElement( $e ); + } +} + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.4/om/xsComplexContent.php b/1.4.0/dom/codeGen/1.4/om/xsComplexContent.php new file mode 100644 index 0000000..2dd1d74 --- /dev/null +++ b/1.4.0/dom/codeGen/1.4/om/xsComplexContent.php @@ -0,0 +1,24 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +class xsComplexContent extends _elementSet +{ + function xsComplexContent() + { + $this->_addElement( 'xsRestriction', array( 'minOccurs' => '1', 'maxOccurs' => '1' ) ); + $this->_addElement( 'xsExtension', array( 'minOccurs' => '1', 'maxOccurs' => '1' ) ); + +// $this->_addAttribute( 'name', array( 'type' => 'xs:string' ) ); + + $this->type[] = 'xsComplexContent'; + parent::_elementSet(); + } +} + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.4/om/xsComplexType.php b/1.4.0/dom/codeGen/1.4/om/xsComplexType.php new file mode 100644 index 0000000..5333208 --- /dev/null +++ b/1.4.0/dom/codeGen/1.4/om/xsComplexType.php @@ -0,0 +1,222 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +class xsComplexType extends _elementSet +{ + function xsComplexType() + { + $this->_addElement( 'xsAnnotation', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsChoice', array( 'minOccurs' => '1', 'maxOccurs' => '1' ) ); + $this->_addElement( 'xsAttribute', array( 'minOccurs' => '1', 'maxOccurs' => '1' ) ); + $this->_addElement( 'xsSequence', array( 'minOccurs' => '1', 'maxOccurs' => '1' ) ); + $this->_addElement( 'xsAll', array( 'minOccurs' => '1', 'maxOccurs' => '1' ) ); + $this->_addElement( 'xsGroup', array( 'minOccurs' => '1', 'maxOccurs' => '1' ) ); + $this->_addElement( 'xsSimpleContent', array( 'minOccurs' => '1', 'maxOccurs' => '1' ) ); + $this->_addElement( 'xsComplexContent', array( 'minOccurs' => '1', 'maxOccurs' => '1' ) ); + + $this->_addAttribute( 'name', array( 'type' => 'xs:string' ) ); + $this->_addAttribute( 'mixed', array( 'type' => 'xs:string', 'default' => 'false' ) ); + + $this->type[] = 'xsComplexType'; + parent::_elementSet(); + } + + function & generate( $element_context, & $global_elements ) + { + $element_context[] = $this->getAttribute( "name" ); + print implode( ",", $element_context ) . "\n"; + + // Get new factory + $generator = new ElementMeta( $global_elements ); + $generator->setIsAComplexType( true ); + + // Load the class name and a context pre-fix (in case we're inside another element) + $generator->setName( $this->getAttribute( 'name' ) ); + $generator->setContext( $element_context ); + + // Extract any documentation for this node + $a = $this->getElementsByType( 'xsAnnotation' ); + if ( count( $a ) > 0 ) + { + $d = $a[0]->getElementsByType( 'xsDocumentation' ); + if ( count( $d ) > 0 ) + { + $generator->setDocumentation( $d[0]->get() ); + } + } + if ( $this->getAttribute( 'mixed' ) == 'true' ) + { + $generator->setMixed( true ); + } + + $content = $this; // Should only be one + $this->generateComplexType( $content, $generator, $element_context ); + + if ( count( $generator->bag['elements'] ) == 0 ) { + $generator->setIsEmptyContent( true ); + } + + $meta = & $generator->getMeta(); + + if ( count( $element_context ) == 1 ) + { + $global_elements[ $element_context[0] ] = & $meta; + } + + return $meta; + } + + // Flatten choice/all/sequence groups into a single list of contained elements + function flatten( & $element, & $generator, & $context, $maxOccurs ) + { + //print "in flatten "; + $e_list = $element->getElements(); + for( $i=0; $i<count( $e_list ); $i++ ) + { + switch( $e_list[$i]->getType() ) + { + case 'xsChoice': + $generator->setHasChoice( true ); + $generator->addContentModel( 1, $e_list[$i]->getAttribute( 'minOccurs' ), $e_list[$i]->getAttribute( 'maxOccurs' ) ); + // Propagate the maxOccurs down through choice hierarchy (while flattening) + $local_max = $e_list[$i]->getAttribute( 'maxOccurs' ); + if ( $maxOccurs == 'unbounded' || (is_int( $local_max ) && ($maxOccurs > $local_max)) ) + { + $this->flatten( $e_list[$i], $generator, $context, $maxOccurs ); + } else + { + $this->flatten( $e_list[$i], $generator, $context, $local_max ); + } + break; + case 'xsSequence': + $generator->addContentModel( 0, $e_list[$i]->getAttribute( 'minOccurs' ), $e_list[$i]->getAttribute( 'maxOccurs' ) ); + // Propagate the maxOccurs down through choice hierarchy (while flattening) + $local_max = $e_list[$i]->getAttribute( 'maxOccurs' ); + if ( $maxOccurs == 'unbounded' || (is_int( $local_max ) && ($maxOccurs > $local_max)) ) + { + $this->flatten( $e_list[$i], $generator, $context, $maxOccurs ); + } else + { + $this->flatten( $e_list[$i], $generator, $context, $local_max ); + } + break; + case 'xsAll': + $generator->addContentModel( 3, $e_list[$i]->getAttribute( 'minOccurs' ), $e_list[$i]->getAttribute( 'maxOccurs' ) ); + // Propagate the maxOccurs down through choice hierarchy (while flattening) + $local_max = $e_list[$i]->getAttribute( 'maxOccurs' ); + if ( $maxOccurs == 'unbounded' || (is_int( $local_max ) && ($maxOccurs > $local_max)) ) + { + $this->flatten( $e_list[$i], $generator, $context, $maxOccurs ); + } else + { + $this->flatten( $e_list[$i], $generator, $context, $local_max ); + } + break; + case 'xsGroup': + $generator->addContentModel( 2, $e_list[$i]->getAttribute( 'minOccurs' ), $e_list[$i]->getAttribute( 'maxOccurs' ) ); + $generator->addGroup( $e_list[$i] ); + case 'xsElement': + $nm = $e_list[$i]->getAttribute( 'name' ); + if ( $nm == '' ) { $nm = $e_list[$i]->getAttribute( 'ref' ); } + $generator->addContentModel( $nm, $e_list[$i]->getAttribute( 'minOccurs' ), $e_list[$i]->getAttribute( 'maxOccurs' ) ); + //print "found element!\n"; + // If a containing element/group has a maxOccurs > 1, then inherit it (will flag as array in code gen) + if ( $maxOccurs == 'unbounded' || $maxOccurs > 1 ) + { + $e_list[$i]->setAttribute( 'maxOccurs', $maxOccurs ); + } + $generator->addElement( $e_list[$i], $context ); + break; + case 'xsAttribute': + //print "found attribute!\n"; + $generator->addAttribute( $e_list[$i] ); + break; + case 'xsAny': + print "found an any\n"; + $generator->addContentModel( 4, $e_list[$i]->getAttribute( 'minOccurs' ), $e_list[$i]->getAttribute( 'maxOccurs' ) ); + $generator->bag['has_any'] = true; + break; + default: + break; + } + } + $generator->addContentModel( 5, 0, 0 ); //END content model - There will be one extra on every element + } + + //function that reads complex types. will recurse complex type derived heirarchies. + function generateComplexType( $content, & $generator, & $context ) { + //print "in generatecomplextype\n"; + if ( count( $content->getElementsByType( 'xsSimpleContent' ) ) > 0 ) { + //print "found simpleContent!\n"; + $temp = $content->getElementsByType( 'xsSimpleContent' ); + $content = $temp[0]; // Should only be one - now we now find out element's parent class + $temp = & $content->getElements(); + $content = $temp[0]; // Should either be an xsExtension or xsRestriction + $type = $content->getAttribute( 'base' ); + //print "setting extends to ". $type ."\n"; + $generator->setContentType( $type ); + $temp = & $content->getElementsByType( 'xsAttribute' ); + for( $i=0; $i<count( $temp ); $i++ ) { + $generator->addAttribute( $temp[$i] ); + } + } else if ( count( $content->getElementsByType( 'xsComplexContent' ) ) > 0 ) { + //print "found complexContent!\n"; + //ComplexContent specified means type is derived + $temp = $content->getElementsByType( 'xsComplexContent' ); + $content = $temp[0]; // Should only be one - now we now find out element's parent class + $temp = & $content->getElements(); + $content = $temp[0]; // Should either be an xsExtension or xsRestriction + if ( $content->getType() == 'xsExtension' ) { + $generator->bag['isExtension'] = true; + } + if ( $content->getType() == 'xsRestriction' ) { + $generator->bag['isRestriction'] = true; + } + $type = $content->getAttribute( 'base' ); + //print "setting extends to ". $type ."\n"; + $generator->bag['base_type'] = $type; + //Generate the complex type this is derived from + //*************CHANGE NEEDED HERE 8-25 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + for ( $i = 0; $i < count( $GLOBALS['_globals']['complex_types'] ); $i++ ) { + if ( $type == $GLOBALS['_globals']['complex_types'][$i]->getAttribute('name') ) { + $generator->setComplexType( true ); + $generator->bag['ref_elements'][] = $type; + //$this->generateComplexType( $GLOBALS['_globals']['complex_types'][$i], $generator, $context ); + break; + } + } + + // Parse element context + $this->flatten( $content, $generator, $element_context, $content->getAttribute( 'maxOccurs' ) ); + + } else { + //print "found nothing so doing complex content flatten\n"; + // The alternative to xsSimpleContent is xsComplexContent - if it is not specified, it is implied + // Parse element context + $this->flatten( $content, $generator, $element_context, $content->getAttribute( 'maxOccurs' ) ); + if ( count( $generator->bag['elements'] ) == 0 ) { + $generator->setIsEmptyContent( true ); + } + } + } + + function & generateType() { + $vars = array(); + $e = $this->getElements(); + $generator = new TypeMeta(); + + $generator->setType( $this->getAttribute( 'name' ) ); + $generator->setIsComplex( true ); + + $meta = & $generator->getMeta(); + return $meta; + } +} + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.4/om/xsDocumentation.php b/1.4.0/dom/codeGen/1.4/om/xsDocumentation.php new file mode 100644 index 0000000..a89ca8e --- /dev/null +++ b/1.4.0/dom/codeGen/1.4/om/xsDocumentation.php @@ -0,0 +1,19 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +class xsDocumentation extends _typedData +{ + function xsDocumentation() + { + $this->type[] = "xsDocumentation"; + parent::_typedData(); + } +} + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.4/om/xsElement.php b/1.4.0/dom/codeGen/1.4/om/xsElement.php new file mode 100644 index 0000000..1aa0c8e --- /dev/null +++ b/1.4.0/dom/codeGen/1.4/om/xsElement.php @@ -0,0 +1,368 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +require_once( 'src/ElementMeta.php' ); +require_once( 'src/TypeMeta.php' ); + +class xsElement extends _elementSet +{ + function xsElement() + { + $this->_addElement( 'xsAnnotation', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsComplexType', array( 'minOccurs' => '0', 'maxOccurs' => '1' ) ); + $this->_addElement( 'xsSimpleType', array( 'minOccurs' => '0', 'maxOccurs' => '1' ) ); + + $this->_addAttribute( 'ref', array( 'type' => 'xs:string' ) ); + $this->_addAttribute( 'name', array( 'type' => 'xs:string' ) ); + $this->_addAttribute( 'type', array( 'type' => 'xs:string' ) ); + $this->_addAttribute( 'abstract', array( 'type' => 'xs:bool' ) ); + $this->_addAttribute( 'substitutionGroup', array( 'type' => 'xs:string' ) ); +// $this->_addAttribute( 'maxOccurs', array( 'type' => 'xs:integer' ) ); +// $this->_addAttribute( 'minOccurs', array( 'type' => 'xs:integer' ) ); + + $this->type[] = 'xsElement'; + parent::_elementSet(); + } + + function & generate( $element_context, & $global_elements ) + { + $element_context[] = $this->getAttribute( "name" ); + print implode( ",", $element_context ) . "\n"; + + // Get new factory + $generator = new ElementMeta( $global_elements ); + + // Load the class name and a context pre-fix (in case we're inside another element) + $generator->setName( $this->getAttribute( 'name' ) ); + $generator->setContext( $element_context ); + $subGroup = $this->getAttribute( 'substitutionGroup' ); + if ( $subGroup != '' ) { + //print "found a subGroup ". $subGroup ."!\n"; + $generator->setSubstitutionGroup( $subGroup ); + $generator->bag['ref_elements'][] = $subGroup; + } + $abstract = $this->getAttribute( 'abstract' ); + if ( $abstract != '' ) { + $generator->setAbstract( $abstract ); + } + + // Extract any documentation for this node + $a = $this->getElementsByType( 'xsAnnotation' ); + if ( count( $a ) > 0 ) + { + $d = $a[0]->getElementsByType( 'xsDocumentation' ); + if ( count( $d ) > 0 ) + { + $generator->setDocumentation( $d[0]->get() ); + } + $ap = $a[0]->getElementsByType( 'xsAppinfo' ); + if ( count( $ap ) > 0 ) + { + $generator->setAppInfo( $ap[0]->get() ); + } + } + + //******************************************************************************************/ + //$generator->setContentType( $this->getAttribute( 'type' ) ); + $type = $this->getAttribute( 'type' ); + $generator->bag['base_type'] = $type; + //check if this type equals a complex type + //print "element ". $this->getAttribute( 'name' ) ." is of type ". $type ."!\n"; + if ( $type != "" ) { + //print "complex types: " . count($GLOBALS['_globals']['complex_types']) . "\n"; + for ( $i = 0; $i < count( $GLOBALS['_globals']['complex_types'] ); $i++ ) { + if ( !strcmp($type, $GLOBALS['_globals']['complex_types'][$i]->getAttribute('name') ) ) { + //print "found a match for ". $type ."\n"; + $generator->setComplexType( true ); + $generator->bag['ref_elements'][] = $type; + break; + } + } + if ( !$generator->bag['complex_type'] ) { + //wasn't a complex type that means it needs a content type + $generator->setContentType( $type ); + } + } + //*******************************************************************************************/ + + // Inspect the semantic structure of this node and extract the elements/attributes + $temp = $this->getElementsByType( 'xsComplexType' ); + + if ( count( $temp ) > 0 ) + { + if ( $temp[0]->getAttribute( 'mixed' ) == 'true' ) + { + $generator->setMixed( true ); + $generator->setContentType( 'ListOfInts' ); + } + + $content = $temp[0]; // Should only be one + $this->generateComplexType( $content, $generator, $element_context ); + if ( count( $generator->bag['elements'] ) == 0 ) { + $generator->setIsEmptyContent( true ); + } + } + else if ( count( $this->getElementsByType( 'xsSimpleType' ) ) > 0 ) { + //inline simple type definition. right now handle as string but needs to be fixed + $generator->bag['simple_type'] = new TypeMeta(); + $temp = $this->getElementsByType( 'xsSimpleType' ); + $this->generateSimpleType( $temp[0], $generator->bag['simple_type'] ); + if ( count( $generator->bag['simple_type']->bag['enum'] ) >0 ) { + $generator->setContentType( $this->getAttribute( 'name' ) ."_type" ); + } + else { + $generator->setContentType( $generator->bag['simple_type']->bag['base'] ); + } + } + + $meta = & $generator->getMeta(); + + if ( count( $element_context ) == 1 ) + { + $global_elements[ $element_context[0] ] = & $meta; + } + + return $meta; + } + + // Flatten choice/all/sequence groups into a single list of contained elements + function flatten( & $element, & $generator, & $context, $maxOccurs ) + { + //print "in flatten "; + $e_list = $element->getElements(); + for( $i=0; $i<count( $e_list ); $i++ ) + { + switch( $e_list[$i]->getType() ) + { + case 'xsChoice': + $generator->setHasChoice( true ); + $generator->addContentModel( 1, $e_list[$i]->getAttribute( 'minOccurs' ), $e_list[$i]->getAttribute( 'maxOccurs' ) ); + // Propagate the maxOccurs down through choice hierarchy (while flattening) + $local_max = $e_list[$i]->getAttribute( 'maxOccurs' ); + if ( $maxOccurs == 'unbounded' || (is_int( $local_max ) && ($maxOccurs > $local_max)) ) + { + $this->flatten( $e_list[$i], $generator, $context, $maxOccurs ); + } else + { + $this->flatten( $e_list[$i], $generator, $context, $local_max ); + } + break; + case 'xsSequence': + $generator->addContentModel( 0, $e_list[$i]->getAttribute( 'minOccurs' ), $e_list[$i]->getAttribute( 'maxOccurs' ) ); + // Propagate the maxOccurs down through choice hierarchy (while flattening) + $local_max = $e_list[$i]->getAttribute( 'maxOccurs' ); + if ( $maxOccurs == 'unbounded' || (is_int( $local_max ) && ($maxOccurs > $local_max)) ) + { + $this->flatten( $e_list[$i], $generator, $context, $maxOccurs ); + } else + { + $this->flatten( $e_list[$i], $generator, $context, $local_max ); + } + break; + case 'xsAll': + $generator->addContentModel( 3, $e_list[$i]->getAttribute( 'minOccurs' ), $e_list[$i]->getAttribute( 'maxOccurs' ) ); + // Propagate the maxOccurs down through choice hierarchy (while flattening) + $local_max = $e_list[$i]->getAttribute( 'maxOccurs' ); + if ( $maxOccurs == 'unbounded' || (is_int( $local_max ) && ($maxOccurs > $local_max)) ) + { + $this->flatten( $e_list[$i], $generator, $context, $maxOccurs ); + } else + { + $this->flatten( $e_list[$i], $generator, $context, $local_max ); + } + break; + case 'xsGroup': + $generator->addContentModel( 2, $e_list[$i]->getAttribute( 'minOccurs' ), $e_list[$i]->getAttribute( 'maxOccurs' ) ); + $generator->addGroup( $e_list[$i] ); + case 'xsElement': + $nm = $e_list[$i]->getAttribute( 'name' ); + if ( $nm == '' ) { $nm = $e_list[$i]->getAttribute( 'ref' ); } + $generator->addContentModel( $nm, $e_list[$i]->getAttribute( 'minOccurs' ), $e_list[$i]->getAttribute( 'maxOccurs' ) ); + //print "found element!\n"; + // If a containing element/group has a maxOccurs > 1, then inherit it (will flag as array in code gen) + if ( $maxOccurs == 'unbounded' || $maxOccurs > 1 ) + { + $e_list[$i]->setAttribute( 'maxOccurs', $maxOccurs ); + } + $generator->addElement( $e_list[$i], $context ); + break; + case 'xsAttribute': + //print "found attribute!\n"; + $generator->addAttribute( $e_list[$i] ); + break; + case 'xsAny': + print "found an any\n"; + $generator->addContentModel( 4, $e_list[$i]->getAttribute( 'minOccurs' ), $e_list[$i]->getAttribute( 'maxOccurs' ) ); + $generator->bag['has_any'] = true; + break; + default: + break; + } + } + $generator->addContentModel( 5, 0, 0 ); //END content model - There will be one extra on every element + } + + //function that reads complex types. will recurse complex type derived heirarchies. + function generateComplexType( $content, & $generator, & $context ) { + //print "in generatecomplextype\n"; + if ( count( $content->getElementsByType( 'xsSimpleContent' ) ) > 0 ) { + //print "found simpleContent!\n"; + $temp = $content->getElementsByType( 'xsSimpleContent' ); + $content = $temp[0]; // Should only be one - now we now find out element's parent class + $temp = & $content->getElements(); + $content = $temp[0]; // Should either be an xsExtension or xsRestriction + $type = $content->getAttribute( 'base' ); + //print "setting extends to ". $type ."\n"; + $generator->setContentType( $type ); + $temp = & $content->getElementsByType( 'xsAttribute' ); + for( $i=0; $i<count( $temp ); $i++ ) { + $generator->addAttribute( $temp[$i] ); + } + } else if ( count( $content->getElementsByType( 'xsComplexContent' ) ) > 0 ) { + //print "found complexContent!\n"; + //ComplexContent specified means type is derived + $temp = $content->getElementsByType( 'xsComplexContent' ); + $content = $temp[0]; // Should only be one - now we now find out element's parent class + $temp = & $content->getElements(); + $content = $temp[0]; // Should either be an xsExtension or xsRestriction + if ( $content->getType() == 'xsExtension' ) { + $generator->bag['isExtension'] = true; + } + if ( $content->getType() == 'xsRestriction' ) { + $generator->bag['isRestriction'] = true; + } + $type = $content->getAttribute( 'base' ); + //print "setting extends to ". $type ."\n"; + $generator->bag['base_type'] = $type; + //Generate the complex type this is derived from + for ( $i = 0; $i < count( $GLOBALS['_globals']['complex_types'] ); $i++ ) { + if ( $type == $GLOBALS['_globals']['complex_types'][$i]->getAttribute('name') ) { + $generator->setComplexType( true ); + $generator->bag['ref_elements'][] = $type; + //$this->generateComplexType( $GLOBALS['_globals']['complex_types'][$i], $generator, $context ); + break; + } + } + + // Parse element context + $this->flatten( $content, $generator, $element_context, $content->getAttribute( 'maxOccurs' ) ); + + } else { + //print "found nothing so doing complex content flatten\n"; + // The alternative to xsSimpleContent is xsComplexContent - if it is not specified, it is implied + // Parse element context + $this->flatten( $content, $generator, $element_context, $content->getAttribute( 'maxOccurs' ) ); + + } + } + + //function that generates the inline simpleType + function generateSimpleType( $content, & $generator ) { + + $e = $content->getElements(); + $generator->setType( $this->getAttribute( 'name' ) ); + //print $this->getAttribute( 'name' ) ." has a simpletype\n"; + $a = $content->getElementsByType( 'xsAnnotation' ); + if ( count( $a ) > 0 ) { + //print "found annotation for ". $this->getAttribute( 'name' ) ."!\n"; + $d = $a[0]->getElementsByType( 'xsDocumentation' ); + if ( count( $d ) > 0 ) + { + //print "found documentation for ". $this->getAttribute( 'name' ) ."!\n"; + $generator->setDocumentation( $d[0]->get() ); + } + $ap = $a[0]->getElementsByType( 'xsAppinfo' ); + if ( count( $ap ) > 0 ) + { + $generator->setAppInfo( $ap[0]->get() ); + } + } + + $idx = 0; + if ( $e[$idx]->getType() == 'xsAnnotation' ) { + $idx = 1; + } + if ( $e[$idx]->getType() == 'xsRestriction' || $e[$idx]->getType() == 'xsExtension' ) + { + $generator->setIsExtension( $e[$idx]->getType() == 'xsExtension' ); + + // Set base class + $generator->setBase( $e[$idx]->getAttribute( 'base' ) ); + + // Look for enums + $enums = $e[$idx]->getElementsByType( 'xsEnumeration' ); + for( $i=0; $i<count( $enums ); $i++ ) + { + $generator->addEnum( $enums[$i]->getAttribute( 'value' ) ); + //print $enums[$i]->getAttribute( 'value' ); + $an = $enums[$i]->getElementsByType('xsAnnotation'); + if ( count( $an ) > 0 ) { + $doc = $an[0]->getElementsByType( 'xsDocumentation' ); + if ( count( $doc ) > 0 ) { + $generator->addEnumDoc( $i, $doc[0]->get() ); + } + $ap = $an[0]->getElementsByType( 'xsAppinfo' ); + if ( count( $ap ) > 0 ) + { + $generator->addEnumAppInfo( $i, $ap[0]->get() ); + } + } + } + + // Look for max/mins + $array_limits = array(); + $min = $e[$idx]->getElementsByType( 'xsMinLength' ); + $max = $e[$idx]->getElementsByType( 'xsMaxLength' ); + $minIn = $e[$idx]->getElementsByType( 'xsMinInclusive' ); + $maxIn = $e[$idx]->getElementsByType( 'xsMaxInclusive' ); + $minEx = $e[$idx]->getElementsByType( 'xsMinExclusive' ); + $maxEx = $e[$idx]->getElementsByType( 'xsMaxExclusive' ); + + if ( count( $min ) > 0 ) + { + $generator->setRestriction( 'minLength', $min[0]->getAttribute( 'value' ) ); + } + + if ( count( $max ) > 0 ) + { + $generator->setRestriction( 'maxLength', $max[0]->getAttribute( 'value' ) ); + } + + if ( count( $minIn ) > 0 ) + { + $generator->setRestriction( 'minInclusive', $minIn[0]->getAttribute( 'value' ) ); + } + + if ( count( $maxIn ) > 0 ) + { + $generator->setRestriction( 'maxInclusive', $maxIn[0]->getAttribute( 'value' ) ); + } + + if ( count( $minEx ) > 0 ) + { + $generator->setRestriction( 'minExclusive', $minEx[0]->getAttribute( 'value' ) ); + } + + if ( count( $maxEx ) > 0 ) + { + $generator->setRestriction( 'maxExclusive', $maxEx[0]->getAttribute( 'value' ) ); + } + } else if ( $e[$idx]->getType() == 'xsList' ) + { + //$extends = "xsList"; + $itemType = $e[$idx]->getAttribute( 'itemType' ); + $generator->setListType( $itemType ); + $generator->bag['isArray'] = true; + } else + { + $this->log( "WARN: unexpected element in xsSimpleType code generation" ); + } + } +} +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.4/om/xsEnumeration.php b/1.4.0/dom/codeGen/1.4/om/xsEnumeration.php new file mode 100644 index 0000000..5b5a2c7 --- /dev/null +++ b/1.4.0/dom/codeGen/1.4/om/xsEnumeration.php @@ -0,0 +1,23 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +class xsEnumeration extends _elementSet +{ + function xsEnumeration() + { + $this->_addAttribute( 'value', array( 'type' => 'xs:integer' ) ); + + $this->_addElement( 'xsAnnotation', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + + $this->type[] = 'xsEnumeration'; + parent::_typedData(); + } +} + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.4/om/xsExtension.php b/1.4.0/dom/codeGen/1.4/om/xsExtension.php new file mode 100644 index 0000000..e0ff68a --- /dev/null +++ b/1.4.0/dom/codeGen/1.4/om/xsExtension.php @@ -0,0 +1,24 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +class xsExtension extends _elementSet +{ + function xsExtension() + { + $this->_addElement( 'xsAttribute', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsSequence', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + + $this->_addAttribute( 'base', array( 'type' => 'xs:string' ) ); + + $this->type[] = 'xsExtension'; + parent::_elementSet(); + } +} + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.4/om/xsGroup.php b/1.4.0/dom/codeGen/1.4/om/xsGroup.php new file mode 100644 index 0000000..4356087 --- /dev/null +++ b/1.4.0/dom/codeGen/1.4/om/xsGroup.php @@ -0,0 +1,152 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +class xsGroup extends _elementSet +{ + function xsGroup() + { + $this->_addElement( 'xsAnnotation', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsElement', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsAttribute', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsChoice', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsSequence', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsGroup', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + + $this->_addAttribute( 'ref', array( 'type' => 'xs:string' ) ); + $this->_addAttribute( 'name', array( 'type' => 'xs:string' ) ); + + $this->type[] = "xsGroup"; + parent::_elementSet(); + } + + function addChoiceElement( & $e ) + { + $this->addElement( $e ); + } + + function & generate( $element_context, & $global_elements ) + { + $element_context[] = $this->getAttribute( "name" ); + print implode( ",", $element_context ) . "\n"; + + // Get new factory + $generator = new ElementMeta( $global_elements ); + $generator->setIsAGroup( true ); + + // Load the class name and a context pre-fix (in case we're inside another element) + $generator->setName( $this->getAttribute( 'name' ) ); + $generator->setContext( $element_context ); + + // Extract any documentation for this node + $a = $this->getElementsByType( 'xsAnnotation' ); + if ( count( $a ) > 0 ) + { + $d = $a[0]->getElementsByType( 'xsDocumentation' ); + if ( count( $d ) > 0 ) + { + $generator->setDocumentation( $d[0]->get() ); + } + } + + // Inspect the semantic structure of this node and extract the elements/attributes + $this->flatten( $this, $generator, $element_context, $this->getAttribute( 'maxOccurs' ) ); + + if ( count( $generator->bag['elements'] ) == 0 ) { + $generator->setIsEmptyContent( true ); + } + + $meta = & $generator->getMeta(); + + if ( count( $element_context ) == 1 ) + { + $global_elements[ $element_context[0] ] = & $meta; + } + + return $meta; + } + + // Flatten choice/all/sequence groups into a single list of contained elements + function flatten( & $element, & $generator, & $context, $maxOccurs ) + { + //print "in flatten "; + $e_list = $element->getElements(); + for( $i=0; $i<count( $e_list ); $i++ ) + { + switch( $e_list[$i]->getType() ) + { + case 'xsChoice': + $generator->setHasChoice( true ); + $generator->addContentModel( 1, $e_list[$i]->getAttribute( 'minOccurs' ), $e_list[$i]->getAttribute( 'maxOccurs' ) ); + // Propagate the maxOccurs down through choice hierarchy (while flattening) + $local_max = $e_list[$i]->getAttribute( 'maxOccurs' ); + if ( $maxOccurs == 'unbounded' || (is_int( $local_max ) && ($maxOccurs > $local_max)) ) + { + $this->flatten( $e_list[$i], $generator, $context, $maxOccurs ); + } else + { + $this->flatten( $e_list[$i], $generator, $context, $local_max ); + } + break; + case 'xsSequence': + $generator->addContentModel( 0, $e_list[$i]->getAttribute( 'minOccurs' ), $e_list[$i]->getAttribute( 'maxOccurs' ) ); + // Propagate the maxOccurs down through choice hierarchy (while flattening) + $local_max = $e_list[$i]->getAttribute( 'maxOccurs' ); + if ( $maxOccurs == 'unbounded' || (is_int( $local_max ) && ($maxOccurs > $local_max)) ) + { + $this->flatten( $e_list[$i], $generator, $context, $maxOccurs ); + } else + { + $this->flatten( $e_list[$i], $generator, $context, $local_max ); + } + break; + case 'xsAll': + $generator->addContentModel( 3, $e_list[$i]->getAttribute( 'minOccurs' ), $e_list[$i]->getAttribute( 'maxOccurs' ) ); + // Propagate the maxOccurs down through choice hierarchy (while flattening) + $local_max = $e_list[$i]->getAttribute( 'maxOccurs' ); + if ( $maxOccurs == 'unbounded' || (is_int( $local_max ) && ($maxOccurs > $local_max)) ) + { + $this->flatten( $e_list[$i], $generator, $context, $maxOccurs ); + } else + { + $this->flatten( $e_list[$i], $generator, $context, $local_max ); + } + break; + case 'xsGroup': + $generator->addContentModel( 2, $e_list[$i]->getAttribute( 'minOccurs' ), $e_list[$i]->getAttribute( 'maxOccurs' ) ); + $generator->addGroup( $e_list[$i] ); + case 'xsElement': + $nm = $e_list[$i]->getAttribute( 'name' ); + if ( $nm == '' ) { $nm = $e_list[$i]->getAttribute( 'ref' ); } + $generator->addContentModel( $nm, $e_list[$i]->getAttribute( 'minOccurs' ), $e_list[$i]->getAttribute( 'maxOccurs' ) ); + //print "found element!\n"; + // If a containing element/group has a maxOccurs > 1, then inherit it (will flag as array in code gen) + if ( $maxOccurs == 'unbounded' || $maxOccurs > 1 ) + { + $e_list[$i]->setAttribute( 'maxOccurs', $maxOccurs ); + } + $generator->addElement( $e_list[$i], $context ); + break; + case 'xsAttribute': + //print "found attribute!\n"; + $generator->addAttribute( $e_list[$i] ); + break; + case 'xsAny': + print "found an any\n"; + $generator->addContentModel( 4, $e_list[$i]->getAttribute( 'minOccurs' ), $e_list[$i]->getAttribute( 'maxOccurs' ) ); + $generator->bag['has_any'] = true; + break; + default: + break; + } + } + $generator->addContentModel( 5, 0, 0 ); //END content model - There will be one extra on every element + } +} + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.4/om/xsImport.php b/1.4.0/dom/codeGen/1.4/om/xsImport.php new file mode 100644 index 0000000..1f5e6d0 --- /dev/null +++ b/1.4.0/dom/codeGen/1.4/om/xsImport.php @@ -0,0 +1,22 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +class xsImport extends _typedData +{ + function xsImport() + { + $this->_addAttribute( 'namespace', array( 'type' => 'xs:string' ) ); + $this->_addAttribute( 'schemaLocation', array( 'type' => 'xs:string' ) ); + + $this->type[] = 'xsImport'; + parent::_typedData(); + } +} + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.4/om/xsList.php b/1.4.0/dom/codeGen/1.4/om/xsList.php new file mode 100644 index 0000000..b1ce038 --- /dev/null +++ b/1.4.0/dom/codeGen/1.4/om/xsList.php @@ -0,0 +1,49 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +class xsList extends _typedData +{ + var $minLength; + var $maxLength; + + function xsList() + { + global $MAX_ARRAY_LENGTH; + + $this->minLength = 0; + $this->maxLength = $MAX_ARRAY_LENGTH; + + $this->_addAttribute( 'itemType', array( 'type' => 'xs:string' ) ); + $this->setAttribute( 'itemType', 'TypedData' ); + + $this->type[] = 'xsList'; + parent::_typedData(); + } + + // To save the heavyweight object-per-data-point approach, allow a list type + // to parse the buffer into a single array + function set( & $buffer ) + { + eval( '$type = new ' . $this->getAttribute( 'itemType' ) . '();' ); + $this->data = & $type->parse( $buffer ); + +/* for( $i=0; trim( $buffer ) != "" && $i<$this->maxLength; $i++ ) + { + eval( '$this->data[ $i ] = new ' . $this->getAttribute( 'itemType' ) . '();' ); + $this->data[ $i ]->set( $buffer ); + }*/ + } + + function getCount() + { + return count( $this->data ); + } +} + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.4/om/xsMaxExclusive.php b/1.4.0/dom/codeGen/1.4/om/xsMaxExclusive.php new file mode 100644 index 0000000..8abec02 --- /dev/null +++ b/1.4.0/dom/codeGen/1.4/om/xsMaxExclusive.php @@ -0,0 +1,21 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +class xsMaxExclusive extends _typedData +{ + function xsMaxExclusive() + { + $this->_addAttribute( 'value', array( 'type' => 'xs:float' ) ); + + $this->type[] = 'xsMaxExclusive'; + parent::_typedData(); + } +} + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.4/om/xsMaxInclusive.php b/1.4.0/dom/codeGen/1.4/om/xsMaxInclusive.php new file mode 100644 index 0000000..8707dc9 --- /dev/null +++ b/1.4.0/dom/codeGen/1.4/om/xsMaxInclusive.php @@ -0,0 +1,21 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +class xsMaxInclusive extends _typedData +{ + function xsMaxInclusive() + { + $this->_addAttribute( 'value', array( 'type' => 'xs:float' ) ); + + $this->type[] = 'xsMaxInclusive'; + parent::_typedData(); + } +} + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.4/om/xsMaxLength.php b/1.4.0/dom/codeGen/1.4/om/xsMaxLength.php new file mode 100644 index 0000000..6394e9b --- /dev/null +++ b/1.4.0/dom/codeGen/1.4/om/xsMaxLength.php @@ -0,0 +1,21 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +class xsMaxLength extends _typedData +{ + function xsMaxLength() + { + $this->_addAttribute( 'value', array( 'type' => 'xs:integer' ) ); + + $this->type[] = 'xsMaxLength'; + parent::_typedData(); + } +} + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.4/om/xsMinExclusive.php b/1.4.0/dom/codeGen/1.4/om/xsMinExclusive.php new file mode 100644 index 0000000..4f02bd3 --- /dev/null +++ b/1.4.0/dom/codeGen/1.4/om/xsMinExclusive.php @@ -0,0 +1,21 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +class xsMinExclusive extends _typedData +{ + function xsMinExclusive() + { + $this->_addAttribute( 'value', array( 'type' => 'xs:float' ) ); + + $this->type[] = 'xsMinExclusive'; + parent::_typedData(); + } +} + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.4/om/xsMinInclusive.php b/1.4.0/dom/codeGen/1.4/om/xsMinInclusive.php new file mode 100644 index 0000000..34ee962 --- /dev/null +++ b/1.4.0/dom/codeGen/1.4/om/xsMinInclusive.php @@ -0,0 +1,21 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +class xsMinInclusive extends _typedData +{ + function xsMinInclusive() + { + $this->_addAttribute( 'value', array( 'type' => 'xs:float' ) ); + + $this->type[] = 'xsMinInclusive'; + parent::_typedData(); + } +} + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.4/om/xsMinLength.php b/1.4.0/dom/codeGen/1.4/om/xsMinLength.php new file mode 100644 index 0000000..809243f --- /dev/null +++ b/1.4.0/dom/codeGen/1.4/om/xsMinLength.php @@ -0,0 +1,21 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +class xsMinLength extends _typedData +{ + function xsMinLength() + { + $this->_addAttribute( 'value', array( 'type' => 'xs:integer' ) ); + + $this->type[] = 'xsMinLength'; + parent::_typedData(); + } +} + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.4/om/xsPattern.php b/1.4.0/dom/codeGen/1.4/om/xsPattern.php new file mode 100644 index 0000000..f679594 --- /dev/null +++ b/1.4.0/dom/codeGen/1.4/om/xsPattern.php @@ -0,0 +1,23 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +class xsPattern extends _elementSet +{ + function xsPattern() + { + $this->_addAttribute( 'value', array( 'type' => 'xs:string' ) ); + + $this->_addElement( 'xsAnnotation', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + + $this->type[] = 'xsPattern'; + parent::_typedData(); + } +} + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.4/om/xsRestriction.php b/1.4.0/dom/codeGen/1.4/om/xsRestriction.php new file mode 100644 index 0000000..61a96b0 --- /dev/null +++ b/1.4.0/dom/codeGen/1.4/om/xsRestriction.php @@ -0,0 +1,32 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +class xsRestriction extends _elementSet +{ + function xsRestriction() + { + $this->_addElement( 'xsAttribute', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsMinLength', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsMaxLength', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsMinInclusive', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsMaxInclusive', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsMinExclusive', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsMaxExclusive', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsEnumeration', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsWhiteSpace', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsPattern', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + + $this->_addAttribute( 'base', array( 'type' => 'xs:string' ) ); + + $this->type[] = 'xsRestriction'; + parent::_elementSet(); + } +} + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.4/om/xsSchema.php b/1.4.0/dom/codeGen/1.4/om/xsSchema.php new file mode 100644 index 0000000..c0b5d8b --- /dev/null +++ b/1.4.0/dom/codeGen/1.4/om/xsSchema.php @@ -0,0 +1,32 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +class xsSchema extends _elementSet +{ + function xsSchema() + { + $this->_addElement( 'xsAnnotation', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsElement', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsSimpleType', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsComplexType', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsGroup', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsImport', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + + $this->_addAttribute( 'targetNamespace', array( 'type' => 'xs:string' ) ); + $this->_addAttribute( 'elementFormDefault', array( 'type' => 'xs:string' ) ); + $this->_addAttribute( 'xmlns:xs', array( 'type' => 'xs:string' ) ); + $this->_addAttribute( 'xmlns', array( 'type' => 'xs:string' ) ); + $this->_addAttribute( 'version', array( 'type' => 'xs:string' ) ); + + $this->type[] = 'xsSchema'; + parent::_elementSet(); + } +} + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.4/om/xsSequence.php b/1.4.0/dom/codeGen/1.4/om/xsSequence.php new file mode 100644 index 0000000..280d253 --- /dev/null +++ b/1.4.0/dom/codeGen/1.4/om/xsSequence.php @@ -0,0 +1,32 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +class xsSequence extends _elementSet +{ + function xsSequence() + { + $this->_addElement( 'xsElement', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsAttribute', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsChoice', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsSequence', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsGroup', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsAny', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsAnnotation', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + + $this->type[] = "xsSequence"; + parent::_elementSet(); + } + + function addSequenceElement( & $e ) + { + $this->addElement( $e ); + } +} + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.4/om/xsSimpleContent.php b/1.4.0/dom/codeGen/1.4/om/xsSimpleContent.php new file mode 100644 index 0000000..2001cea --- /dev/null +++ b/1.4.0/dom/codeGen/1.4/om/xsSimpleContent.php @@ -0,0 +1,24 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +class xsSimpleContent extends _elementSet +{ + function xsSimpleContent() + { + $this->_addElement( 'xsRestriction', array( 'minOccurs' => '1', 'maxOccurs' => '1' ) ); + $this->_addElement( 'xsExtension', array( 'minOccurs' => '1', 'maxOccurs' => '1' ) ); + +// $this->_addAttribute( 'name', array( 'type' => 'xs:string' ) ); + + $this->type[] = 'xsSimpleContent'; + parent::_elementSet(); + } +} + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.4/om/xsSimpleType.php b/1.4.0/dom/codeGen/1.4/om/xsSimpleType.php new file mode 100644 index 0000000..5b40cbe --- /dev/null +++ b/1.4.0/dom/codeGen/1.4/om/xsSimpleType.php @@ -0,0 +1,143 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +require_once( 'src/TypeMeta.php' ); + +class xsSimpleType extends _elementSet +{ + function xsSimpleType() + { + $this->_addElement( 'xsRestriction', array( 'minOccurs' => '1', 'maxOccurs' => '1' ) ); + $this->_addElement( 'xsExtension', array( 'minOccurs' => '1', 'maxOccurs' => '1' ) ); + $this->_addElement( 'xsList', array( 'minOccurs' => '1', 'maxOccurs' => '1' ) ); + $this->_addElement( 'xsUnion', array( 'minOccurs' => '1', 'maxOccurs' => '1' ) ); + + $this->_addElement( 'xsAnnotation', array( 'minOccurs' => '1', 'maxOccurs' => '1' ) ); + + $this->_addAttribute( 'name', array( 'type' => 'xs:string' ) ); + + $this->type[] = 'xsSimpleType'; + parent::_elementSet(); + } + + function & generate() + { + $vars = array(); + $e = $this->getElements(); + $generator = new TypeMeta(); + + $generator->setType( $this->getAttribute( 'name' ) ); + + $a = $this->getElementsByType( 'xsAnnotation' ); + if ( count( $a ) > 0 ) + { + //print "found annotation for ". $this->getAttribute( 'name' ) ."!\n"; + $d = $a[0]->getElementsByType( 'xsDocumentation' ); + if ( count( $d ) > 0 ) + { + //print "found documentation for ". $this->getAttribute( 'name' ) ."!\n"; + $generator->setDocumentation( $d[0]->get() ); + } + $ap = $a[0]->getElementsByType( 'xsAppinfo' ); + if ( count( $ap ) > 0 ) + { + $generator->setAppInfo( $ap[0]->get() ); + } + } + + $idx = 0; + if ( $e[$idx]->getType() == 'xsAnnotation' ) { + $idx = 1; + } + if ( $e[$idx]->getType() == 'xsRestriction' || $e[$idx]->getType() == 'xsExtension' ) + { + $generator->setIsExtension( $e[$idx]->getType() == 'xsExtension' ); + + // Set base class + $generator->setBase( $e[$idx]->getAttribute( 'base' ) ); + + // Look for enums + $enums = $e[$idx]->getElementsByType( 'xsEnumeration' ); + for( $i=0; $i<count( $enums ); $i++ ) + { + $generator->addEnum( $enums[$i]->getAttribute( 'value' ) ); + $an = $enums[$i]->getElementsByType('xsAnnotation'); + if ( count( $an ) > 0 ) { + $doc = $an[0]->getElementsByType( 'xsDocumentation' ); + if ( count( $doc ) > 0 ) { + $generator->addEnumDoc( $i, $doc[0]->get() ); + } + $ap = $an[0]->getElementsByType( 'xsAppinfo' ); + if ( count( $ap ) > 0 ) + { + $generator->addEnumAppInfo( $i, $ap[0]->get() ); + } + } + } + + // Look for max/mins + $array_limits = array(); + $min = $e[$idx]->getElementsByType( 'xsMinLength' ); + $max = $e[$idx]->getElementsByType( 'xsMaxLength' ); + $minIn = $e[$idx]->getElementsByType( 'xsMinInclusive' ); + $maxIn = $e[$idx]->getElementsByType( 'xsMaxInclusive' ); + $minEx = $e[$idx]->getElementsByType( 'xsMinExclusive' ); + $maxEx = $e[$idx]->getElementsByType( 'xsMaxExclusive' ); + + if ( count( $min ) > 0 ) + { + $generator->setRestriction( 'minLength', $min[0]->getAttribute( 'value' ) ); + } + + if ( count( $max ) > 0 ) + { + $generator->setRestriction( 'maxLength', $max[0]->getAttribute( 'value' ) ); + } + + if ( count( $minIn ) > 0 ) + { + $generator->setRestriction( 'minInclusive', $minIn[0]->getAttribute( 'value' ) ); + } + + if ( count( $maxIn ) > 0 ) + { + $generator->setRestriction( 'maxInclusive', $maxIn[0]->getAttribute( 'value' ) ); + } + + if ( count( $minEx ) > 0 ) + { + $generator->setRestriction( 'minExclusive', $minEx[0]->getAttribute( 'value' ) ); + } + + if ( count( $maxEx ) > 0 ) + { + $generator->setRestriction( 'maxExclusive', $maxEx[0]->getAttribute( 'value' ) ); + } + } else if ( $e[$idx]->getType() == 'xsList' ) + { + //$extends = "xsList"; + $itemType = $e[$idx]->getAttribute( 'itemType' ); + $generator->setListType( $itemType ); + $generator->bag['isArray'] = true; + } + else if ( $e[$idx]->getType() == 'xsUnion' ) { + $generator->setUnionMembers( $e[$idx]->getAttribute( 'memberTypes' ) ); + } + else + { + $this->log( "WARN: unexpected element in xsSimpleType code generation" ); + } + + $meta = & $generator->getMeta(); + return $meta; + } +} + + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.4/om/xsUnion.php b/1.4.0/dom/codeGen/1.4/om/xsUnion.php new file mode 100644 index 0000000..79954ad --- /dev/null +++ b/1.4.0/dom/codeGen/1.4/om/xsUnion.php @@ -0,0 +1,21 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +class xsUnion extends _typedData +{ + function xsUnion() + { + $this->_addAttribute( 'memberTypes', array( 'type' => 'xs:string' ) ); + + $this->type[] = 'xsUnion'; + parent::_typedData(); + } +} + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.4/om/xsWhiteSpace.php b/1.4.0/dom/codeGen/1.4/om/xsWhiteSpace.php new file mode 100644 index 0000000..a968f0e --- /dev/null +++ b/1.4.0/dom/codeGen/1.4/om/xsWhiteSpace.php @@ -0,0 +1,21 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +class xsWhiteSpace extends _typedData +{ + function xsWhiteSpace() + { + $this->_addAttribute( 'value', array( 'type' => 'xs:string' ) ); + + $this->type[] = 'xsWhiteSpace'; + parent::_typedData(); + } +} + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.4/src/ElementMeta.php b/1.4.0/dom/codeGen/1.4/src/ElementMeta.php new file mode 100644 index 0000000..b7b9882 --- /dev/null +++ b/1.4.0/dom/codeGen/1.4/src/ElementMeta.php @@ -0,0 +1,280 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +class ElementMeta +{ + var $pre_name; + var $name; + //var $extends; + var $doc; + + var $bag; + + function ElementMeta( & $global_elements ) + { + $bag = array( + 'has_id_attr' => false, + 'context' => '', + 'pre_name' => '', + 'content_type' => '', + 'base_type' => '', + 'documentation' => array(), + 'element_name' => '', + 'elements' => array(), + 'inline_elements' => array(), + 'ref_elements' => array(), + 'element_attrs' => array(), + 'attributes' => array(), + 'mixed' => false, + 'complex_type' => false, + 'abstract' => false, + 'substitution_group' => '', + 'element_documentation' => array(), + 'useXMLNS' => false, + 'hasChoice' => false, + 'isEmptyContent' => false, + 'groupElements' => array(), + 'isAComplexType' => false, + 'isAGroup' => false, + 'substitutableWith' => array(), + 'isExtension' => false, + 'isRestriction' => false, + 'simple_type' => NULL, + 'parent_meta' => NULL, + 'has_any' => false, + 'content_model' => array() + ); + + $this->bag = & $bag; + $this->bag['global_elements'] = & $global_elements; + } + + function addGroup( & $e ) { + $this->bag['groupElements'][] = $e->getAttribute('ref'); + } + + function setSubstitutionGroup( $subGroup ) { + $this->bag['substitution_group'] = trim( $subGroup ); + } + + function setComplexType( $bool ) { + $this->bag['complex_type'] = ( $bool == true ); + } + + function setAbstract( $bool ) { + $this->bag['abstract'] = ( $bool == true ); + } + + function setHasChoice( $bool ) { + $this->bag['hasChoice'] = $bool; + } + + function setIsEmptyContent( $bool ) { + $this->bag['isEmptyContent'] = $bool; + } + + function setIsAComplexType( $bool ) { + $this->bag['isAComplexType'] = ( $bool == true ); + } + + function setIsAGroup( $bool ) { + $this->bag['isAGroup'] = ( $bool == true ); + } + + function & getMeta() + { + return $this->bag; + } + + function setMixed( $bool ) + { + $this->bag['mixed'] = ( $bool == true ); + } + + function setContentType( $type ) + { + // Strip xs if we've got a built-in type + /*if ( preg_match( "/xs\:/", $type ) ) + { + $type = 'xs' . substr( $type, 3 ); + }*/ + // If type is non-empty, then go ahead and set it + if ( preg_match( "/[^\s]+/", $type ) ) + { + $this->bag['content_type'] = trim( $type ); + } + } + + function setMinOccurs( $min ) + { + if ( is_int( $min ) && $min >= 0 ) + { + $this->bag['minOccurs'] = $min; + } + } + + function setMaxOccurs( $max ) + { + if ( $max == 'unbounded' || (is_int( $max ) && $max >= 1 ) ) + { + $this->bag['maxOccurs'] = $max; + } + } + + function setPreName( $pre ) + { + $this->pre_name = $pre; + $this->bag['pre_name'] = $pre; + } + + function setName( $name ) + { + $this->name = $name; + $this->bag['element_name'] = $name; + } + + function getName() + { + return $this->name; + } + + function setHasID( $bool ) + { + $this->bag['has_id_attr'] = $bool; + } + + function setDocumentation( $doc ) + { + $this->doc = $doc; + $this->bag['documentation']['en'] = trim( $doc ); + } + + function setAppInfo( $ap ) { + if (!strcmp( trim($ap), 'enable-xmlns' ) ) { + //use the xmlns attribute + $this->bag['useXMLNS'] = true; + } + } + + function setContext( $context ) + { + $this->bag['context'] = $context; + } + + function addElement( & $e, $context ) + { + $name = 'undefined'; + $ref_element = false; + $_attributes = array(); + + foreach( $e->getAttributes() as $k => $v ) + { + $_attributes[ $k ] = $v; + + if ( $k == 'ref' ) + { + $name = $v; + $ref_element = true; + } + else if ( $k == 'name' ) + { + $name = $v; + } + } + + //check if this element already exists this only applies if in a sequence. + foreach( $this->bag['elements'] as $nm ) { + if ( $nm == $name ) { + //print "found duplicate element upping max occurs"; + //if it does then update its max occurs and exit + if ( !$this->bag['hasChoice'] || $_attributes['maxOccurs'] == 'unbounded' ) { + if ( $this->bag['element_attrs'][$nm]['maxOccurs'] != 'unbounded' ) { + $this->bag['element_attrs'][$nm]['maxOccurs']++; + } + } + //print " to ". $this->bag['element_attrs'][$nm]['maxOccurs'] ."\n"; + return; + } + } + + // Track the attrs on each sub-element + $this->bag['element_attrs'][ $name ] = & $_attributes; + + // Call the dom-recurse function on each new element + if ( !$ref_element ) + { + $this->bag['elements'][] = $name; + $this->bag['inline_elements'][ $name ] = & $e->generate( $this->bag['context'], $this->bag['global_elements'] ); + $this->bag['element_documentation'][$name] = $this->bag['inline_elements'][ $name ]['documentation']['en']; + $this->bag['inline_elements'][ $name ]['parent_meta'] = & $this->bag; + } + else { + $this->bag['elements'][] = $name; + $this->bag['ref_elements'][] = $name; + //check for documentation + $a = $e->getElementsByType( 'xsAnnotation' ); + if ( count( $a ) > 0 ) { + $d = $a[0]->getElementsByType( 'xsDocumentation' ); + if ( count( $d ) > 0 ) + { + $this->bag['element_documentation'][$name] = $d[0]->get(); + } + } + } + + } + + function addAttribute( & $a ) + { + $name = ''; + $a_list = array(); + + foreach( $a->getAttributes() as $k => $v ) + { + $a_list[ $k ] = $v; + if ( $k == 'name' ) + { + $name = $v; + if ( $name == 'id' ) { $this->bag['has_id_attr'] = true; } + } + else if ( $k == 'ref' ) { + $name = $v; + //printf( "found an attribute ref for ". $name ."\n"); + if ( strpos( $name, ':' ) !== FALSE ) { + $name[strpos( $name, ':' )] = '_'; + //printf( "changed : to _ for ". $name ."\n" ); + $a_list[ 'type' ] = 'xs:anyURI'; + } + } + } + //check for documentation + $e = $a->getElementsByType( 'xsAnnotation' ); + if ( count( $e ) > 0 ) + { + $d = $e[0]->getElementsByType( 'xsDocumentation' ); + if ( count( $d ) > 0 ) + { + $a_list['documentation'] = $d[0]->get(); + } + } + + $this->bag['attributes'][ $name ] = & $a_list; + + //print "adding attribute ". $name ."\n"; + } + + //For elements name is the element name, for sequence name = 0, choice = 1, group = 2, all = 3, any = 4, end = 5 + function addContentModel( $name, $minOccurs, $maxOccurs ) + { + $this->bag['content_model'][] = array( 'name' => $name, 'minOccurs' => $minOccurs, 'maxOccurs' => $maxOccurs ); + print "adding content model name: ". $name ." minO: ". $minOccurs ." maxO: ". $maxOccurs ."\n"; + } +} + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.4/src/SchemaParser.php b/1.4.0/dom/codeGen/1.4/src/SchemaParser.php new file mode 100644 index 0000000..b44b806 --- /dev/null +++ b/1.4.0/dom/codeGen/1.4/src/SchemaParser.php @@ -0,0 +1,80 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +require_once( 'om/object-model.php' ); + +class SchemaParser +{ + var $parse_stack = array(); + var $root_elements = array(); + var $parser; + + function SchemaParser() + { + $this->parser = xml_parser_create(); + + xml_parser_set_option( $this->parser, XML_OPTION_CASE_FOLDING, false ); + xml_set_object( $this->parser, $this ); + xml_set_element_handler( $this->parser, "startElement", "endElement" ); + xml_set_character_data_handler( $this->parser, "characterData" ); + + //xml_parser_free( $this->parser ); + } + + function startElement( $parser, $name, $attrs ) + { + if ( preg_match( "/xs\:/", $name ) ) + { + $class_name = substr( $name, 3 ); + $class_name = 'xs' . ucfirst( $class_name ); + + eval( '$e = new ' . $class_name . '();' ); + foreach( $attrs as $k => $v ) { $e->setAttribute( $k, $v ); } + + if ( count( $this->parse_stack ) > 0 ) + { + $this->parse_stack[ count( $this->parse_stack ) - 1 ]->addElement( $e ); + } else + { + $this->root_elements[] = & $e; + } + $this->parse_stack[] = & $e; + } + } + + function endElement( $parser, $name ) + { + $pop = & array_pop( $this->parse_stack ); + } + + function characterData( $parser, $data ) + { + if ( count( $this->parse_stack ) > 0 ) + { + $this->parse_stack[ count( $this->parse_stack ) - 1 ]->append( $data ); + } + } + + function parse( $file ) + { + if ( file_exists( $file ) ) + { + if ( !xml_parse( $this->parser, file_get_contents( $file ) ) ) + { + // Got parse error + } + } else + { + // Bad file + } + } + +} + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.4/src/TypeMeta.php b/1.4.0/dom/codeGen/1.4/src/TypeMeta.php new file mode 100644 index 0000000..f7f46fc --- /dev/null +++ b/1.4.0/dom/codeGen/1.4/src/TypeMeta.php @@ -0,0 +1,108 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +class TypeMeta +{ + var $bag; + + function TypeMeta() + { + $bag = array( + 'type' => '', + 'base' => '', + 'listType' => '', + 'enum' => array(), + 'enum_documentation' => array(), + 'restrictions' => array(), + 'isExtension' => true, + 'isComplex' => false, + 'useConstStrings' =>false, + 'documentation' => array(), + 'isArray' => false, + 'enum_value' => array(), + 'union_type' => false, + 'union_members' => '' + ); + $this->bag = & $bag; + } + + function & getMeta() + { + return $this->bag; + } + + function setType( $t ) + { + $this->bag['type'] = $t; + } + + function setBase( $b ) + { + $this->bag['base'] = $b; + } + + function setListType( $type ) + { + $this->bag['listType'] = $type; + } + + function setIsExtension( $bool ) + { + $this->bag['isExtension'] = $bool; + } + + function setIsComplex( $bool ) { + $this->bag['isComplex'] = $bool; + } + + function setRestriction( $name, $val ) + { + $this->bag['restrictions'][$name] = $val; + } + + function addEnum( $val ) + { + $this->bag['enum'][] = $val; + } + + function setAppInfo( $ap ) { + if (!strcmp( trim($ap), 'constant-strings' ) ) { + //use the xmlns attribute + $this->bag['useConstStrings'] = true; + } + } + + function setDocumentation( $doc ) + { + $this->doc = $doc; + $this->bag['documentation']['en'] = trim( $doc ); + } + + function addEnumDoc( $i, $doc ) { + $this->bag['enum_documentation'][$i] = trim($doc); + } + + function addEnumAppInfo( $i, $ai ) { + $ai = trim($ai); + //print "found app info\n"; + if ( strncmp($ai, "value=", 6) == 0 ) { + //print "its in the correct format\n"; + $val = substr($ai, 6); + //print "value is ". $val ."\n"; + $this->bag['enum_value'][$i] = trim($val); + } + } + + function setUnionMembers( $um ) { + $this->bag['union_type'] = true; + $this->bag['union_members'] = $um; + } +} + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.4/tpl/template-engine.php b/1.4.0/dom/codeGen/1.4/tpl/template-engine.php new file mode 100644 index 0000000..d0160c1 --- /dev/null +++ b/1.4.0/dom/codeGen/1.4/tpl/template-engine.php @@ -0,0 +1,469 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +$_globals = array(); +// FLAG: Full Code - set true to output verbose mode, minimal otherwise (does not include// inline elements in minimal) +$_globals['full_code'] = true; +$_globals['copyright'] = false; +$_globals['copyright_text'] = "/*\n" . +" * Copyright 2006 Sony Computer Entertainment Inc.\n" . +" *\n" . +" * Licensed under the SCEA Shared Source License, Version 1.0 (the \"License\"); you may not use this\n" . +" * file except in compliance with the License. You may obtain a copy of the License at:\n" . +" * http://research.scea.com/scea_shared_source_license.html\n" . +" *\n" . +" * Unless required by applicable law or agreed to in writing, software distributed under the License\n" . +" * is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n" . +" * implied. See the License for the specific language governing permissions and limitations under the\n" . +" * License.\n" . +" */\n\n"; + +$_globals['depth'] = 0; +$_globals['meta_prefix'] = 'dae'; +$_globals['prefix'] = 'dom'; +$_globals['language'] = 'en'; +$_globals['dom_dir'] = 'gen/dom/'; +$_globals['tmp_dir'] = 'tmp/'; +$_globals['log_file'] = 'gen/gen.log'; + +$_globals['register_list'] = array(); +$_globals['include_list'] = array(); +$_globals['complex_types'] = array(); +$_globals['groups'] = array(); +$_globals['constStrings'] = array(); //used to store all the constant strings needed to be put in the file. +$_globals['elementTypes'] = array(); +$_globals['elementNames'] = array(); +$_globals['elementNames'][] = "COLLADA"; //needed because no elements have this as a child. +$_globals['typeID'] = 0; + +$_globals['target_dir'] = ''; + +$_globals['global_elements'] = array(); + +$_globals['templates'] = array( + 'DOXYGEN' => 'tpl/tpl-doxygen.php', + 'TYPES_HEADER_FILE' => 'tpl/tpl-types-header-file.php', + 'TYPES_HEADER' => 'tpl/tpl-types-header.php', + 'TYPES_CPP_FILE' => 'tpl/tpl-types-cpp-file.php', + 'TYPES_CPP' => 'tpl/tpl-types-cpp.php', + 'INCLUDES' => 'tpl/tpl-includes.php', + 'HEADER' => 'tpl/tpl-dot-h.php', + 'HEADER_FILE' => 'tpl/tpl-header.php', + 'INCLUDE_LIST' => 'tpl/tpl-include-list.php', + 'CPP_FILE' => 'tpl/tpl-cpp.php', + 'CPP' => 'tpl/tpl-cpp-body.php', + 'CPP_STATIC' => 'tpl/tpl-cpp-static.php', + 'CPP_METHODS' => 'tpl/tpl-cpp-methods.php', + 'CLASS' => 'tpl/tpl-class-def.php', + 'ELEMENTS_FILE' => 'tpl/tpl-elements-file.php', + 'ELEMENTS' => 'tpl/tpl-elements.php', + 'CONSTANTS_FILE' => 'tpl/tpl-constants-file.php', + 'CONSTANTS' => 'tpl/tpl-constants.php', + 'CONSTANTS_CPP_FILE' => 'tpl/tpl-constants-cpp-file.php', + 'CONSTANTS_CPP' => 'tpl/tpl-constants-cpp.php' +); + +function applyTemplate( $template, & $bag ) +{ + global $_globals; + + $_result = ''; + if ( array_key_exists( $template, $_globals['templates'] ) ) + { + ob_start(); + include( $_globals['templates'][ $template ] ); + + $_result = ob_get_contents(); + ob_end_clean(); + } + return $_result; +} + +function initGen( $file ) +{ + global $_globals; + + // A few defns + $_globals['gen_start_time'] = date( "M d Y H:i:s" ); + $_globals['file_name'] = $file; + + // Verify target dirs exist, create if not + makeGenDir( getcwd() . "/gen" ); + makeGenDir( getcwd() . "/" . $_globals['dom_dir'] ); + makeGenDir( getcwd() . "/" . $_globals['dom_dir'] . 'include/' ); + makeGenDir( getcwd() . "/" . $_globals['dom_dir'] . 'src/' ); + + // Start buffering output + ob_start(); +} + +function makeGenDir( $dir ) +{ + if ( !is_dir( $dir ) ) + { + if ( !mkdir( $dir ) ) + { + die( "Could not create directory $dir\n" ); + } + } +} + +function cleanupGen() +{ + global $_globals; + + // Get output buffer + $_result = ob_get_contents(); + ob_end_clean(); + // Assemble report + ob_start(); + print "========================================\n\n"; + print " Code Generation\n\n"; + print "----------------------------------------\n"; + print "COLLADA File: " . $_globals['file_name'] . "\n"; + print "Start time: " . $_globals['gen_start_time'] . "\n"; + print "End time: " . date( "M d Y H:i:s" ) . "\n"; + print "----------------------------------------\n\n"; + print $_result; + print "\r\n\r\nend\r\n"; + file_put_contents( $_globals['log_file'], ob_get_contents() ); + ob_end_clean(); + print "Generation complete\n"; +} + +function saveTemplate( $file, $template, & $bag ) +{ + $bytes = file_put_contents( $file, applyTemplate( $template, $bag ) ); +} + +function printAllSubChildren( & $elem, $prefix, $suffix ) { + //print "subchild test count = ". count( $elem['elements'] ) ."\n"; + //print "subchild test name = ". $elem['element_name'] ."\n"; + global $_globals; + global $meta; + for ( $i = 0; $i < count( $elem['elements'] ); $i++ ) { + if ( isset( $meta[$elem['elements'][$i]] ) ) { + if ( $meta[$elem['elements'][$i]]['isAGroup'] ) { + + printAllSubChildren( $meta[$elem['elements'][$i]], $prefix, $suffix ); + } + else if ( !$meta[$elem['elements'][$i]]['abstract'] ) { + print $prefix ."_Meta->children.append(\"". $elem['elements'][$i] ."\");". $suffix; + print ");\n"; + } + for( $c = 0; $c < count( $meta[$elem['elements'][$i]]['substitutableWith']); $c++ ) { + $subwith = $meta[$elem['elements'][$i]]['substitutableWith'][$c]; + print $prefix ."_Meta->children.append(\"". $subwith ."\");". $suffix; + print ");\n"; + } + } + else { + print $prefix . $elem['elements'][$i] . $suffix; + if ( isset($meta[$elem['element_attrs'][ $elem['elements'][$i] ]['type']]) && + $meta[$elem['element_attrs'][ $elem['elements'][$i] ]['type']]['isAComplexType'] ) { + print ", \"". $elem['element_attrs'][ $elem['elements'][$i] ]['type'] ."\""; + } + print ");\n"; + } + } +} + +function getInheritanceStatement($baseClasses) { + if (count($baseClasses) == 0) + return ""; + $statement = " : public " . $baseClasses[0]; + for ($i = 1; $i < count($baseClasses); $i++) + $statement .= ", public " . $baseClasses[$i]; + return $statement; +} + +function beginConstructorInitializer(& $initializerListStarted) { + print $initializerListStarted ? ", " : " : "; + $initializerListStarted = true; +} + +function printBaseClassInitializers($elemName, $baseClasses, & $initializerListStarted) { + $elt = strpos($elemName, "_complexType") === false ? "this" : "elt"; + for ($i = 0; $i < count($baseClasses); $i++) { + beginConstructorInitializer($initializerListStarted); + print $baseClasses[$i] . + (strpos($baseClasses[$i], "_complexType") !== false ? "(dae, " . $elt . ")" : "(dae)"); + } +} + +function printConstructors( $elemName, & $bag, $baseClasses, $indent ) { + //print the protected ctor and copy stuff + print $indent ."protected:\n"; + print $indent ."\t/**\n". $indent ."\t * Constructor\n". $indent ."\t */\n"; + print $indent ."\t". $elemName ."(DAE& dae"; + if ($bag['isAComplexType']) + print ", daeElement* elt"; + print ")"; + $initializerListStarted = false; + $eltVar = $bag['isAComplexType'] ? "*elt" : "*this"; + + printBaseClassInitializers($elemName, $baseClasses, $initializerListStarted); + + if ($bag['useXMLNS']) { + beginConstructorInitializer($initializerListStarted); + print "attrXmlns(dae, " . $eltVar . ")"; + } + + // Constructor initialization of attributes + if (count($bag['attributes']) > 0) { + foreach( $bag['attributes'] as $attr_name => & $a_list ) { + beginConstructorInitializer($initializerListStarted); + + $attr_name = ucfirst($attr_name); + $type = $a_list['type']; + print "attr" . $attr_name . "("; + if ($type == 'xs:anyURI' || $type == 'URIFragmentType') + print "dae, " . $eltVar; + else if ($type == 'xs:IDREF') + print $eltVar; + else if ($type == 'xs:IDREFS') + print "new xsIDREF(" . $eltVar . ")"; + print ")"; + } + } + + // Constructor initialization of elements + for( $i=0; $i<count( $bag['elements'] ); $i++ ) { + $maxOccurs = $bag['element_attrs'][ $bag['elements'][$i] ]['maxOccurs']; + $maxOccurs = ($maxOccurs == 'unbounded' || $maxOccurs > 1); + beginConstructorInitializer($initializerListStarted); + print "elem" . ucfirst($bag['elements'][$i]) . ($maxOccurs ? "_array" : "") . "()"; + } + + if ( ($bag['content_type'] != '' || $bag['mixed']) && !$bag['abstract'] ) { + beginConstructorInitializer($initializerListStarted); + if ($bag['content_type'] == 'xs:anyURI' || $bag['content_type'] == 'URIFragmentType') + print "_value(dae, " . $eltVar . ")"; + else if ($bag['content_type'] == 'xs:IDREF') + print "_value(" . $eltVar . ")"; + else if ($bag['content_type'] == 'xs:IDREFS') + print "_value(new xsIDREF(" . $eltVar . "))"; + else + print "_value()"; + } + print " {}\n"; + + print $indent ."\t/**\n". $indent ."\t * Destructor\n". $indent ."\t */\n"; + print $indent ."\tvirtual ~". $elemName ."() {"; + if ( $bag['hasChoice'] ) { + print " daeElement::deleteCMDataArray(_CMData); "; + } + print "}\n"; + + print $indent ."\t/**\n". $indent ."\t * Overloaded assignment operator\n". $indent ."\t */\n"; + print $indent ."\tvirtual ".$elemName ." &operator=( const ".$elemName ." &cpy ) { (void)cpy; return *this; }\n"; +} + +function printAttributes( & $bag, & $typemeta, & $indent, $vaa ) { + global $_globals; + + $attrCnt = 0; + if ( $bag['useXMLNS'] ) { + //comment + print $indent ."\t/**\n". $indent ."\t * Gets the xmlns attribute.\n"; + print $indent ."\t * @return Returns a xsAnyURI reference of the xmlns attribute.\n"; + print $indent ."\t */\n"; + //code + print $indent ."\txsAnyURI &getXmlns() { return attrXmlns; }\n"; + //comment + print $indent ."\t/**\n". $indent ."\t * Gets the xmlns attribute.\n"; + print $indent ."\t * @return Returns a constant xsAnyURI reference of the xmlns attribute.\n"; + print $indent ."\t */\n"; + //code + print $indent ."\tconst xsAnyURI &getXmlns() const { return attrXmlns; }\n"; + //comment + print $indent ."\t/**\n". $indent ."\t * Sets the xmlns attribute.\n"; + print $indent ."\t * @param xmlns The new value for the xmlns attribute.\n"; + print $indent ."\t */\n"; + //code + print $indent ."\tvoid setXmlns( const xsAnyURI &xmlns ) { attrXmlns = xmlns;"; + if ( $vaa ) { + print $indent ."\n\t _validAttributeArray[". $attrCnt ."] = true;"; + } + print " }\n\n"; + + $attrCnt++; + } + + foreach( $bag['attributes'] as $attr_name => & $a_list ) { + $type = $a_list['type']; + if ( preg_match( "/xs\:/", $type ) ) { + $type = substr( $type, 3 ); + $pre = "xs"; + } + else { + $pre = $_globals['prefix']; + } + if ( $type == '' ) + { + $type = "String"; + } + $baseStringTypes = "xsDateTime xsID xsNCName xsNMTOKEN xsName xsToken xsString"; + $baseType = $pre . ucfirst( $type ); + if ( isset( $typemeta[$type] ) ) { + $typeInfo = $typemeta[$type]; + while ( $typeInfo['base'] != '' && isset( $typemeta[$typeInfo['base']] ) ) { + $typeInfo = $typemeta[$typeInfo['base']]; + if ( preg_match( "/xs\:/", $typeInfo['type'] ) ) { + $baseType = "xs" . ucfirst( substr( $typeInfo['type'], 3 ) ); + } + else { + $baseType = $_globals['prefix'] . ucfirst( $typeInfo['type'] ); + } + } + } + + if ( (isset( $typemeta[$type] ) && $typemeta[$type]['isArray']) || $type == 'IDREFS' ) { + //comment + print $indent ."\t/**\n". $indent ."\t * Gets the ". $attr_name ." array attribute.\n"; + print $indent ."\t * @return Returns a ". $pre . ucfirst( $type ) ." reference of the ". $attr_name ." array attribute.\n"; + print $indent ."\t */\n"; + //code + print $indent ."\t" . $pre . ucfirst( $type ) . " &get" . ucfirst($attr_name) ."() { "; + print "return attr". ucfirst($attr_name) ."; }\n"; + //comment + print $indent ."\t/**\n". $indent ."\t * Gets the ". $attr_name ." array attribute.\n"; + print $indent ."\t * @return Returns a constant ". $pre . ucfirst( $type ) ." reference of the ". $attr_name ." array attribute.\n"; + print $indent ."\t */\n"; + //code + print $indent ."\tconst " . $pre . ucfirst( $type ) . " &get" . ucfirst($attr_name) ."() const { "; + print "return attr". ucfirst($attr_name) ."; }\n"; + //comment + print $indent ."\t/**\n". $indent ."\t * Sets the ". $attr_name ." array attribute.\n"; + print $indent ."\t * @param at". ucfirst($attr_name)." The new value for the ". $attr_name ." array attribute.\n"; + print $indent ."\t */\n"; + //code + print $indent ."\tvoid set". ucfirst( $attr_name ) ."( const ". $pre . ucfirst( $type ) ." &at"; + print ucfirst($attr_name) ." ) { attr". ucfirst($attr_name) ." = at". ucfirst($attr_name) .";"; + if ( $vaa ) { + print " _validAttributeArray[". $attrCnt ."] = true;"; + } + print " }\n\n"; + } + else if ( ucfirst($type) == 'AnyURI' || ucfirst($type) == 'URIFragmentType' ) { + //comment + print $indent ."\t/**\n". $indent ."\t * Gets the ". $attr_name ." attribute.\n"; + print $indent ."\t * @return Returns a ". $pre . ucfirst( $type ) ." reference of the ". $attr_name ." attribute.\n"; + print $indent ."\t */\n"; + //code + print $indent ."\t" . $pre . ucfirst( $type ) . " &get" . ucfirst($attr_name) ."() { "; + print "return attr". ucfirst($attr_name) ."; }\n"; + //comment + print $indent ."\t/**\n". $indent ."\t * Gets the ". $attr_name ." attribute.\n"; + print $indent ."\t * @return Returns a constant ". $pre . ucfirst( $type ) ." reference of the ". $attr_name ." attribute.\n"; + print $indent ."\t */\n"; + //code + print $indent ."\tconst " . $pre . ucfirst( $type ) . " &get" . ucfirst($attr_name) ."() const { "; + print "return attr". ucfirst($attr_name) ."; }\n"; + //comment + print $indent ."\t/**\n". $indent ."\t * Sets the ". $attr_name ." attribute.\n"; + print $indent ."\t * @param at". ucfirst($attr_name)." The new value for the ". $attr_name ." attribute.\n"; + print $indent ."\t */\n"; + //code + print $indent ."\tvoid set". ucfirst( $attr_name ) ."( const ". $pre . ucfirst( $type ) ." &at"; + print ucfirst($attr_name) ." ) { attr". ucfirst($attr_name) ." = at". ucfirst($attr_name) .";"; + if ( $vaa ) { + print " _validAttributeArray[". $attrCnt ."] = true;"; + } + print " }\n"; + // We add a setter that takes a plain string to help with backward compatibility + //comment + print $indent ."\t/**\n". $indent ."\t * Sets the ". $attr_name ." attribute.\n"; + print $indent ."\t * @param at". ucfirst($attr_name)." The new value for the ". $attr_name ." attribute.\n"; + print $indent ."\t */\n"; + //code + print $indent ."\tvoid set". ucfirst( $attr_name ) ."( xsString at"; + print ucfirst($attr_name) ." ) { attr". ucfirst($attr_name) ." = at" . ucfirst($attr_name) . ";"; + if ( $vaa ) { + print " _validAttributeArray[". $attrCnt ."] = true;"; + } + print " }\n\n"; + } + else if( ucfirst($type) == 'IDREF' ) { + //comment + print $indent ."\t/**\n". $indent ."\t * Gets the ". $attr_name ." attribute.\n"; + print $indent ."\t * @return Returns a ". $pre . ucfirst( $type ) ." reference of the ". $attr_name ." attribute.\n"; + print $indent ."\t */\n"; + //code + print $indent ."\t" . $pre . ucfirst( $type ) . " &get" . ucfirst($attr_name) ."() { "; + print "return attr". ucfirst($attr_name) ."; }\n"; + //comment + print $indent ."\t/**\n". $indent ."\t * Gets the ". $attr_name ." attribute.\n"; + print $indent ."\t * @return Returns a constant ". $pre . ucfirst( $type ) ." reference of the ". $attr_name ." attribute.\n"; + print $indent ."\t */\n"; + //code + print $indent ."\tconst " . $pre . ucfirst( $type ) . " &get" . ucfirst($attr_name) ."() const{ "; + print "return attr". ucfirst($attr_name) ."; }\n"; + //comment + print $indent ."\t/**\n". $indent ."\t * Sets the ". $attr_name ." attribute.\n"; + print $indent ."\t * @param at". ucfirst($attr_name)." The new value for the ". $attr_name ." attribute.\n"; + print $indent ."\t */\n"; + //code + print $indent ."\tvoid set". ucfirst( $attr_name ) ."( const ". $pre . ucfirst( $type ) ." &at"; + print ucfirst($attr_name) ." ) { attr". ucfirst($attr_name) ." = at". ucfirst($attr_name) .";"; + if ( $vaa ) { + print " _validAttributeArray[". $attrCnt ."] = true;"; + } + print " }\n\n"; + } + else if ( strstr( $baseStringTypes, $baseType ) !== FALSE && count( $a_list['enum'] ) == 0 ) { + //comment + print $indent ."\t/**\n". $indent ."\t * Gets the ". $attr_name ." attribute.\n"; + print $indent ."\t * @return Returns a ". $pre . ucfirst( $type ) ." of the ". $attr_name ." attribute.\n"; + print $indent ."\t */\n"; + //code + print $indent ."\t" . $pre . ucfirst( $type ) . " get" . ucfirst($attr_name) ."() const { "; + print "return attr". ucfirst($attr_name) ."; }\n"; + //comment + print $indent ."\t/**\n". $indent ."\t * Sets the ". $attr_name ." attribute.\n"; + print $indent ."\t * @param at". ucfirst($attr_name)." The new value for the ". $attr_name ." attribute.\n"; + print $indent ."\t */\n"; + //code + print $indent ."\tvoid set". ucfirst( $attr_name ) ."( ". $pre . ucfirst( $type ) ." at"; + print ucfirst($attr_name) ." ) { *(daeStringRef*)&attr". ucfirst($attr_name) ." = at". ucfirst($attr_name) .";"; + if ( $vaa ) { + print " _validAttributeArray[". $attrCnt ."] = true; "; + } + if ( $attr_name == "id" ) + { + print "\n". $indent ."\t\tif( _document != NULL ) _document->changeElementID( this, attrId );\n". $indent ."\t"; + } + + print "}\n\n"; + } + else { + //comment + print $indent ."\t/**\n". $indent ."\t * Gets the ". $attr_name ." attribute.\n"; + print $indent ."\t * @return Returns a ". $pre . ucfirst( $type ) ." of the ". $attr_name ." attribute.\n"; + print $indent ."\t */\n"; + //code + print $indent ."\t" . $pre . ucfirst( $type ) . " get" . ucfirst($attr_name) ."() const { "; + print "return attr". ucfirst($attr_name) ."; }\n"; + //comment + print $indent ."\t/**\n". $indent ."\t * Sets the ". $attr_name ." attribute.\n"; + print $indent ."\t * @param at". ucfirst($attr_name)." The new value for the ". $attr_name ." attribute.\n"; + print $indent ."\t */\n"; + //code + print $indent ."\tvoid set". ucfirst( $attr_name ) ."( ". $pre . ucfirst( $type ) ." at"; + print ucfirst($attr_name) ." ) { attr". ucfirst($attr_name) ." = at". ucfirst($attr_name) .";"; + if ( $vaa ) { + print " _validAttributeArray[". $attrCnt ."] = true;"; + } + print " }\n\n"; + } + $attrCnt++; + } +} + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.4/tpl/tpl-class-def.php b/1.4.0/dom/codeGen/1.4/tpl/tpl-class-def.php new file mode 100644 index 0000000..700106e --- /dev/null +++ b/1.4.0/dom/codeGen/1.4/tpl/tpl-class-def.php @@ -0,0 +1,475 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + + global $meta; + global $typemeta; + + // shorthand: + $full_element_name = $_globals['prefix'] . ucfirst( $bag['element_name'] ); + //COLLADA TYPE list + if ( array_search( $bag['element_name'], $_globals['elementTypes'] ) === FALSE ) + { + $_globals['elementTypes'][] = $bag['element_name']; + } + //COLLADA ELEMENT list + for( $i=0; $i<count( $bag['elements'] ); $i++ ) + { + if ( array_search( $bag['elements'][$i], $_globals['elementNames'] ) === FALSE ) + { + $_globals['elementNames'][] = $bag['elements'][$i]; + } + } + if ( $bag['substitution_group'] != '' ) + { + //also add this element to the list of elements. + if ( array_search( $bag['element_name'], $_globals['elementNames'] ) === FALSE ) + { + $_globals['elementNames'][] = $bag['element_name']; + } + } + + $indent = ""; + for ($i = 0; $i < $GLOBALS['indentNum']; $i++ ) { + $indent .= "\t"; + } + if ( $GLOBALS['indentNum'] > 0 ) { //only print these for the inner classes.. the main classes will have + //them defined in a seperate file to avoid circular includes. + print $indent."class " . $full_element_name . ";\n\n"; + print $indent ."typedef daeSmartRef<". $full_element_name ."> ". $full_element_name ."Ref;\n"; + print $indent ."typedef daeTArray<". $full_element_name ."Ref> ". $full_element_name ."_Array;\n\n"; + } + + // DOCUMENTATION + if ( isset( $bag['documentation'][ $_globals['language'] ] ) ) + { + print applyTemplate( 'DOXYGEN', $bag['documentation'][ $_globals['language'] ] ); + } + + // SUBSTITION GROUP/INHERITANCE + $baseClasses = array(); + if ( $bag['isAComplexType'] ) { + if ( $bag['complex_type'] ) + $baseClasses[] = $_globals['prefix'] . ucfirst( $bag['base_type'] ) . "_complexType"; + print $indent ."class ". $full_element_name ."_complexType ". + getInheritanceStatement($baseClasses) ."\n".$indent."{\n"; + } + else { + $baseClasses[] = ($bag['substitution_group'] != '' ? $_globals['prefix'] . ucfirst($bag['substitution_group']) : 'daeElement'); + if ( $bag['complex_type'] ) + $baseClasses[] = $_globals['prefix'] . ucfirst( $bag['base_type'] ) . "_complexType"; + print $indent ."class ". $full_element_name . getInheritanceStatement($baseClasses) . "\n".$indent."{\n"; + print $indent ."public:\n"; + print $indent ."\tvirtual COLLADA_TYPE::TypeEnum getElementType() const { return COLLADA_TYPE::". strtoupper($bag['element_name']) ."; }\n"; + print $indent ."\tstatic daeInt ID() { return ". $_globals['typeID']++ ."; }\n"; + print $indent ."\tvirtual daeInt typeID() const { return ID(); }\n"; + } + + // INTERNAL CLASSES + $result = ''; + $inlines = array_keys( $bag['inline_elements'] ); + for( $i=0; $i<count( $inlines ); $i++ ) + { + $inner = $bag['inline_elements'][ $inlines[$i] ]; + if ( !$inner['complex_type'] || $inner['isRestriction'] || $inner['isExtension'] ) { + $GLOBALS['indentNum']++; + $result .= applyTemplate( 'CLASS', $inner ); + $GLOBALS['indentNum']--; + } + } + if ( strlen( $result ) > 0 ) { print $indent ."public:\n$result\n"; } + + //ENUM + if ( $bag['simple_type'] != NULL ) { + $typeMeta = $bag['simple_type']->getMeta(); + //print $typeMeta['type']; + if ( count( $typeMeta['enum'] ) > 0 ) + { + //print "has enums"; + print $indent ."public: //ENUM\n"; + if ( !$typeMeta['useConstStrings'] ) { + //Decided to name mangle the enum constants so they are more descriptive and avoid collisions + if ( isset( $typeMeta['documentation']['en'] ) ) { + print applyTemplate( 'DOXYGEN', $typeMeta['documentation']['en'] ); + } + print "enum " . $_globals['prefix'] . ucfirst( $typeMeta['type'] ) . "_type {\n"; + //print "\t" . strtoupper( $typeMeta['type'] ) . "_" . $typeMeta['enum'][0] ." = 1"; + for( $i = 0; $i < count( $typeMeta['enum'] ); $i++ ) { + //print ","; + print "\t" . strtoupper( $typeMeta['type'] ) . "_" . $typeMeta['enum'][$i] .","; + if ( isset( $typeMeta['enum_documentation'][$i] ) ) { + print "\t\t/**< ". $typeMeta['enum_documentation'][$i] ." */"; + } + //print "\n\t" . strtoupper( $typeMeta['type'] ) . "_" . $typeMeta['enum'][$i]; + print "\n"; + } + //if ( isset( $typeMeta['enum_documentation'][count( $typeMeta['enum'] )-1] ) ) { + // print "\t\t/**< ". $typeMeta['enum_documentation'][count( $typeMeta['enum'] )-1] ." */"; + //} + print "\t". strtoupper( $typeMeta['type'] ) . "_COUNT"; + print "\n};\n\n"; + } + else { + //if ( isset( $typeMeta['documentation']['en'] ) ) { + // $_globals['constStrings'][] = applyTemplate( 'DOXYGEN', $typeMeta['documentation']['en'] ); + //} + for( $i = 0; $i < count( $typeMeta['enum'] ); $i++ ) { + //print "static const daeString ". strtoupper( $typeMeta['type'] ) . "_" . $typeMeta['enum'][$i]; + //print " = \"". $typeMeta['enum'][$i] ."\";\n"; + if ( isset( $typeMeta['enum_documentation'][$i] ) ) { + $_globals['constStrings'][] = "/**\n * ". $typeMeta['enum_documentation'][$i] ."\n */\n"; + } + $conststrnm = strtoupper( $typeMeta['type'] ) . "_" . $typeMeta['enum'][$i]; + $conststr = "\"". $typeMeta['enum'][$i] ."\";\n"; + $_globals['constStrings'][$conststrnm] = $conststr; + } + $_globals['constStrings'][] = "\n"; + } + } + } + + // ATTRIBUTES + if ( count( $bag['attributes'] ) > 0 || $bag['useXMLNS'] ) + { + print $indent ."protected: // Attribute". (count( $bag['attributes'] ) > 1 ? 's' : '') ."\n"; + + if ( $bag['useXMLNS'] ) { + print $indent ."\t/**\n". $indent ."\t * This element may specify its own xmlns.\n". $indent ."\t */\n"; + print $indent ."\txsAnyURI attrXmlns;\n"; + } + foreach( $bag['attributes'] as $attr_name => & $a_list ) + { + $type = $a_list['type']; + if ( preg_match( "/xs\:/", $type ) ) { + $type = substr( $type, 3 ); + $pre = "xs"; + } + else { + $pre = $_globals['prefix']; + } + if ( $type == '' ) + { + $type = "String"; + } + if ( isset( $a_list['documentation'] ) ) { + print applyTemplate( 'DOXYGEN', $a_list['documentation'] ); + } + print $indent ."\t" . $pre . ucfirst( $type ) . " attr" . ucfirst($attr_name) .";\n"; + } + } + + // ELEMENTS + if ( count( $bag['attributes'] > 0 ) ) { print "\n"; } + + if ( (count( $bag['elements'] ) > 0 && !$bag['isRestriction']) || $bag['has_any'] ) + { + + print $indent ."protected: // Element". (count( $bag['elements'] ) > 1 ? 's' : '') ."\n"; + $needsContents = false; + for( $i=0; $i<count( $bag['elements'] ); $i++ ) + { + $maxOccurs = $bag['element_attrs'][ $bag['elements'][$i] ]['maxOccurs']; +// $minOccurs = $bag['element_attrs'][ $bag['elements'][$i] ]['minOccurs']; +// print " // minOccurs=$minOccurs, maxOccurs=$maxOccurs\n"; + $maxOccurs = ($maxOccurs == 'unbounded' || $maxOccurs > 1); + if ( isset( $bag['element_documentation'][ $bag['elements'][$i] ] ) ) { + $bag['element_documentation'][ $bag['elements'][$i] ] .= " @see " . $_globals['prefix'] . ucfirst( $bag['elements'][$i] ); + print applyTemplate( 'DOXYGEN', $bag['element_documentation'][ $bag['elements'][$i] ] ); + } + if ( isset( $bag['element_attrs'][ $bag['elements'][$i] ]['type'] ) && + isset( $meta[$bag['element_attrs'][ $bag['elements'][$i] ]['type']] ) ){ + print $indent ."\t" . $_globals['prefix'] . ucfirst( $bag['element_attrs'][ $bag['elements'][$i] ]['type'] ) . ($maxOccurs ? "_Array" : "Ref") . " elem" . ucfirst($bag['elements'][$i]) . ($maxOccurs ? "_array" : "") . ";\n"; + } + else { + print $indent ."\t" . $_globals['prefix'] . ucfirst( $bag['elements'][$i] ) . ($maxOccurs ? "_Array" : "Ref") . " elem" . ucfirst($bag['elements'][$i]) . ($maxOccurs ? "_array" : "") . ";\n"; + } + if ( isset( $meta[$bag['elements'][$i]] ) ) { + if( count( $meta[$bag['elements'][$i]]['substitutableWith']) > 0 ) { + $needsContents = true; + } + } + } + if ( $bag['hasChoice'] || $needsContents || $bag['has_any'] ) + { + print $indent ."\t/**\n". $indent ."\t * Used to preserve order in elements that do not specify strict sequencing of sub-elements."; + print "\n". $indent ."\t */\n"; + print $indent ."\tdaeElementRefArray _contents;\n"; + print $indent ."\t/**\n". $indent ."\t * Used to preserve order in elements that have a complex content model."; + print "\n". $indent ."\t */\n"; + print $indent ."\tdaeUIntArray _contentsOrder;\n\n"; + } + if ( $bag['hasChoice'] ) + { + print $indent ."\t/**\n". $indent ."\t * Used to store information needed for some content model objects.\n"; + print $indent ."\t */\n". $indent ."\tdaeTArray< daeCharArray * > _CMData;\n\n"; + } + } + + //VALUE + // NOTE: special casing any element with 'mixed' content model to ListOfInts type _value + if ( ($bag['content_type'] != '' || $bag['mixed']) && !$bag['abstract'] ) + { + print $indent ."protected: // Value\n"; + + $content_type = $bag['content_type']; + if ( preg_match( "/xs\:/", $content_type ) ) { + $content_type = substr( $content_type, 3 ); + $pre = "xs"; + } + else { + $pre = $_globals['prefix']; + } + //if ( !strcmp( $pre . ucfirst( $content_type ), $full_element_name ) ) { + if ( $bag['parent_meta']['inline_elements'] != NULL && array_key_exists( $content_type, $bag['parent_meta']['inline_elements'] ) ) { + $pre = '::' . $pre; + } + print $indent ."\t/**\n". $indent ."\t * The " . $pre . ucfirst( $content_type ) ." value of the text data of this element. "; + print "\n". $indent ."\t */\n"; + print $indent ."\t".$pre . ucfirst( $content_type ) ." _value;\n"; + } + + if ( $bag['complex_type'] && !$bag['isAComplexType'] ) + { + $bag2 = $bag; + $bag2['attributes'] = array_merge( $meta[$bag['base_type']]['attributes'], $bag['attributes'] ); + printAttributes( $bag2, $typemeta, $indent, true ); + } + + if ( $_globals['accessorsAndMutators'] && ( $bag['useXMLNS'] || count($bag['attributes'])>0 || + count($bag['elements'])>0 ||( ($bag['content_type'] != '' || $bag['mixed']) && !$bag['abstract'] ) ) ) { + + //generate accessors and mutators for everything + print "\n". $indent ."public:\t//Accessors and Mutators\n"; + printAttributes( $bag, $typemeta, $indent, !$bag['isAComplexType'] ); + + $needsContents = false; + for( $i=0; $i<count( $bag['elements'] ); $i++ ) { + $maxOccurs = $bag['element_attrs'][ $bag['elements'][$i] ]['maxOccurs']; + $maxOccurs = ($maxOccurs == 'unbounded' || $maxOccurs > 1); + $type = ''; + if ( isset( $bag['element_attrs'][ $bag['elements'][$i] ]['type'] ) && + isset( $meta[$bag['element_attrs'][ $bag['elements'][$i] ]['type']] ) ){ + + $type = $_globals['prefix'] . ucfirst( $bag['element_attrs'][ $bag['elements'][$i] ]['type'] ) . ($maxOccurs ? "_Array" : "Ref"); + } + else { + $type = $_globals['prefix'] . ucfirst( $bag['elements'][$i] ) . ($maxOccurs ? "_Array" : "Ref"); + } + $name = ucfirst($bag['elements'][$i]) . ($maxOccurs ? "_array" : ""); + if ( $maxOccurs ) { + //comment + print $indent ."\t/**\n". $indent ."\t * Gets the ". $bag['elements'][$i] ." element array.\n"; + print $indent ."\t * @return Returns a reference to the array of ". $bag['elements'][$i] ." elements.\n"; + print $indent ."\t */\n"; + //code + print $indent ."\t". $type ." &get". $name ."() { return elem". $name ."; }\n"; + //comment + print $indent ."\t/**\n". $indent ."\t * Gets the ". $bag['elements'][$i] ." element array.\n"; + print $indent ."\t * @return Returns a constant reference to the array of ". $bag['elements'][$i] ." elements.\n"; + print $indent ."\t */\n"; + //code + print $indent ."\tconst ". $type ." &get". $name ."() const { return elem". $name ."; }\n"; + //print $indent ."\tvoid set". $name ."( ". $type ." *e". $name ." ) { elem". $name ." = *e". $name ."; }\n\n"; + } + else { + //comment + print $indent ."\t/**\n". $indent ."\t * Gets the ". $bag['elements'][$i] ." element.\n"; + print $indent ."\t * @return a daeSmartRef to the ". $bag['elements'][$i] ." element.\n"; + print $indent ."\t */\n"; + //code + print $indent ."\tconst ". $type ." get". $name ."() const { return elem". $name ."; }\n"; + //print $indent ."\tvoid set". $name ."( ". $type ." &e". $name ." ) { elem". $name ." = e". $name ."; }\n\n"; + } + + if ( isset( $meta[$bag['elements'][$i]] ) ) { + if( count( $meta[$bag['elements'][$i]]['substitutableWith']) > 0 ) { + $needsContents = true; + } + } + } + + if ( $bag['hasChoice'] || $needsContents || $bag['has_any'] ) + { + //comment + print $indent ."\t/**\n". $indent ."\t * Gets the _contents array.\n"; + print $indent ."\t * @return Returns a reference to the _contents element array.\n"; + print $indent ."\t */\n"; + //code + print $indent ."\tdaeElementRefArray &getContents() { return _contents; }\n"; + //comment + print $indent ."\t/**\n". $indent ."\t * Gets the _contents array.\n"; + print $indent ."\t * @return Returns a constant reference to the _contents element array.\n"; + print $indent ."\t */\n"; + //code + print $indent ."\tconst daeElementRefArray &getContents() const { return _contents; }\n\n"; + } + + if ( ($bag['content_type'] != '' || $bag['mixed']) && !$bag['abstract'] ) + { + $type = $bag['content_type']; + if ( preg_match( "/xs\:/", $type ) ) { + $type = substr( $type, 3 ); + $pre = "xs"; + } + else { + $pre = $_globals['prefix']; + } + $baseStringTypes = "xsDateTime xsID xsNCName xsNMTOKEN xsName xsToken xsString"; + $baseType = $pre . ucfirst( $type ); + if ( isset( $typemeta[$type] ) ) { + $typeInfo = $typemeta[$type]; + while ( $typeInfo['base'] != '' && isset( $typemeta[$typeInfo['base']] ) ) { + $typeInfo = $typemeta[$typeInfo['base']]; + if ( preg_match( "/xs\:/", $typeInfo['type'] ) ) { + $baseType = "xs" . ucfirst( substr( $typeInfo['type'], 3 ) ); + } + else { + $baseType = $_globals['prefix'] . ucfirst( $typeInfo['type'] ); + } + } + } + //if ( !strcmp( $pre . ucfirst( $type ), $full_element_name ) ) { + if ( $bag['parent_meta']['inline_elements'] != NULL && array_key_exists( $type, $bag['parent_meta']['inline_elements'] ) ) { + $pre = '::' . $pre; + } + if ( (isset( $typemeta[$content_type] ) && $typemeta[$content_type]['isArray']) || $content_type == 'IDREFS' ) { + //comment + print $indent ."\t/**\n". $indent ."\t * Gets the _value array.\n"; + print $indent ."\t * @return Returns a ". $pre . ucfirst( $type ) ." reference of the _value array.\n"; + print $indent ."\t */\n"; + //code + print $indent ."\t".$pre . ucfirst( $type ) ." &getValue() { return _value; }\n"; + //comment + print $indent ."\t/**\n". $indent ."\t * Gets the _value array.\n"; + print $indent ."\t * @return Returns a constant ". $pre . ucfirst( $type ) ." reference of the _value array.\n"; + print $indent ."\t */\n"; + //code + print $indent ."\tconst ".$pre . ucfirst( $type ) ." &getValue() const { return _value; }\n"; + //comment + print $indent ."\t/**\n". $indent ."\t * Sets the _value array.\n"; + print $indent ."\t * @param val The new value for the _value array.\n"; + print $indent ."\t */\n"; + //code + print $indent ."\tvoid setValue( const ". $pre . ucfirst( $type ) ." &val ) { _value = val; }\n\n"; + //print $indent ."\t _meta->getValueAttribute()->setIsValid(true); }\n\n"; + } + else if ( ucfirst($type) == 'AnyURI' ) { + //comment + print $indent ."\t/**\n". $indent ."\t * Gets the value of this element.\n"; + print $indent ."\t * @return Returns a ". $pre . ucfirst( $type ) ." of the value.\n"; + print $indent ."\t */\n"; + //code + print $indent ."\t".$pre . ucfirst( $type ) ." &getValue() { return _value; }\n"; + //comment + print $indent ."\t/**\n". $indent ."\t * Gets the value of this element.\n"; + print $indent ."\t * @return Returns a constant ". $pre . ucfirst( $type ) ." of the value.\n"; + print $indent ."\t */\n"; + //code + print $indent ."\tconst ".$pre . ucfirst( $type ) ." &getValue() const { return _value; }\n"; + //comment + print $indent ."\t/**\n". $indent ."\t * Sets the _value of this element.\n"; + print $indent ."\t * @param val The new value for this element.\n"; + print $indent ."\t */\n"; + //code + print $indent ."\tvoid setValue( const ". $pre . ucfirst( $type ) ." &val ) { _value = val; }\n"; + // We add a setter that takes a plain string to help with backward compatibility + //comment + print $indent ."\t/**\n". $indent ."\t * Sets the _value of this element.\n"; + print $indent ."\t * @param val The new value for this element.\n"; + print $indent ."\t */\n"; + //code + print $indent ."\tvoid setValue( xsString val ) { _value = val; }\n\n"; + } + else if( ucfirst($type) == 'IDREF' ) { + //comment + print $indent ."\t/**\n". $indent ."\t * Gets the value of this element.\n"; + print $indent ."\t * @return Returns a ". $pre . ucfirst( $type ) ." of the value.\n"; + print $indent ."\t */\n"; + //code + print $indent ."\t".$pre . ucfirst( $type ) ." &getValue() { return _value; }\n"; + //comment + print $indent ."\t/**\n". $indent ."\t * Gets the value of this element.\n"; + print $indent ."\t * @return Returns a constant ". $pre . ucfirst( $type ) ." of the value.\n"; + print $indent ."\t */\n"; + //code + print $indent ."\tconst ".$pre . ucfirst( $type ) ." &getValue() const { return _value; }\n"; + //comment + print $indent ."\t/**\n". $indent ."\t * Sets the _value of this element.\n"; + print $indent ."\t * @param val The new value for this element.\n"; + print $indent ."\t */\n"; + //code + print $indent ."\tvoid setValue( const ". $pre . ucfirst( $type ) ." &val ) { _value = val; }\n\n"; + //print $indent ."\t _meta->getValueAttribute()->setIsValid(true); }\n\n"; + } + else if ( strstr( $baseStringTypes, $baseType ) !== FALSE && count( $typemeta[$type]['enum'] ) == 0 ) { + //comment + print $indent ."\t/**\n". $indent ."\t * Gets the value of this element.\n"; + print $indent ."\t * @return Returns a ". $pre . ucfirst( $type ) ." of the value.\n"; + print $indent ."\t */\n"; + //code + print $indent ."\t".$pre . ucfirst( $type ) ." getValue() const { return _value; }\n"; + //comment + print $indent ."\t/**\n". $indent ."\t * Sets the _value of this element.\n"; + print $indent ."\t * @param val The new value for this element.\n"; + print $indent ."\t */\n"; + //code + print $indent ."\tvoid setValue( ". $pre . ucfirst( $type ) ." val ) { *(daeStringRef*)&_value = val; }\n\n"; + } + else { + //comment + print $indent ."\t/**\n". $indent ."\t * Gets the value of this element.\n"; + print $indent ."\t * @return a ". $pre . ucfirst( $type ) ." of the value.\n"; + print $indent ."\t */\n"; + //code + print $indent ."\t".$pre . ucfirst( $type ) ." getValue() const { return _value; }\n"; + //comment + print $indent ."\t/**\n". $indent ."\t * Sets the _value of this element.\n"; + print $indent ."\t * @param val The new value for this element.\n"; + print $indent ."\t */\n"; + //code + print $indent ."\tvoid setValue( ". $pre . ucfirst( $type ) ." val ) { _value = val; }\n\n"; + //print $indent ."\t _meta->getValueAttribute()->setIsValid(true); }\n\n"; + } + } + } + + //CONSTRUCTORS + if ( !$bag['isAComplexType'] ) { + printConstructors( $full_element_name, $bag, $baseClasses, $indent ); + } + else { + printConstructors( $full_element_name ."_complexType", $bag, $baseClasses, $indent ); + + print $indent ."};\n\n"; + print $indent ."/**\n". $indent ." * An element of type ". $full_element_name ."_complexType.\n". $indent ." */\n"; + print $indent ."class ". $full_element_name ." : public daeElement, public ". $full_element_name ."_complexType\n"; + print $indent ."{\n"; + print $indent ."public:\n"; + print $indent ."\tvirtual COLLADA_TYPE::TypeEnum getElementType() const { return COLLADA_TYPE::". strtoupper($bag['element_name']) ."; }\n"; + print $indent ."\tstatic daeInt ID() { return ". $_globals['typeID']++ ."; }\n"; + print $indent ."\tvirtual daeInt typeID() const { return ID(); }\n"; + + if ( $_globals['accessorsAndMutators'] && ( $bag['useXMLNS'] || count($bag['attributes'])>0 ) ) { + //generate accessors and mutators for everything + print "\n". $indent ."public:\t//Accessors and Mutators\n"; + printAttributes( $bag, $typemeta, $indent, true ); + } + + $dummy = array(); + printConstructors( $full_element_name, $dummy, array("daeElement", $full_element_name . "_complexType"), $indent ); + } + + print "\n".$indent ."public: // STATIC METHODS\n"; + print $indent ."\t/**\n". $indent ."\t * Creates an instance of this class and returns a daeElementRef referencing it.\n"; + print $indent ."\t * @return a daeElementRef referencing an instance of this object.\n". $indent ."\t */\n"; + print $indent ."\tstatic DLLSPEC ". $_globals['meta_prefix'] ."ElementRef create(DAE& dae);\n"; + print $indent ."\t/**\n". $indent ."\t * Creates a daeMetaElement object that describes this element in the meta object reflection framework."; + print "\n". $indent ."\t * If a daeMetaElement already exists it will return that instead of creating a new one. \n"; + print $indent ."\t * @return A daeMetaElement describing this COLLADA element.\n". $indent ."\t */\n"; + print $indent ."\tstatic DLLSPEC ". $_globals['meta_prefix'] ."MetaElement* registerElement(DAE& dae);\n"; + print $indent ."};\n\n"; diff --git a/1.4.0/dom/codeGen/1.4/tpl/tpl-constants-cpp-file.php b/1.4.0/dom/codeGen/1.4/tpl/tpl-constants-cpp-file.php new file mode 100644 index 0000000..c6141e2 --- /dev/null +++ b/1.4.0/dom/codeGen/1.4/tpl/tpl-constants-cpp-file.php @@ -0,0 +1,16 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +// Grab the file name and save the output +$_file = $_globals['prefix'] . "Constants.cpp"; +$_bytes = file_put_contents( ($_globals['target_dir'] . $_globals['dom_dir'] . 'src/' . $_file), applyTemplate( 'CONSTANTS_CPP', $bag ) ); + +//if ( $_bytes > 0 ) { print "Wrote $_bytes bytes to file '$_file'\n"; } + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.4/tpl/tpl-constants-cpp.php b/1.4.0/dom/codeGen/1.4/tpl/tpl-constants-cpp.php new file mode 100644 index 0000000..30d113d --- /dev/null +++ b/1.4.0/dom/codeGen/1.4/tpl/tpl-constants-cpp.php @@ -0,0 +1,36 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +if ( $_globals['copyright'] ) { +print $_globals['copyright_text']; +} +?> +#include <dom/domConstants.h> + +<?php + foreach ($bag as $name => $val ) { + if ( is_int($name) ) { + print $val; + continue; + } + print "DLLSPEC daeString ". $name ." = ". $val; + } + print "\n"; + + foreach ($_globals['elementTypes'] as $num => $val ) + { + print "DLLSPEC daeString COLLADA_TYPE_". getUniqueName($val, $_globals['elementTypes']) ." = \"". $val ."\";\n"; + } + print "\n"; + + foreach ($_globals['elementNames'] as $num => $val ) + { + print "DLLSPEC daeString COLLADA_ELEMENT_". getUniqueName($val, $_globals['elementNames']) ." = \"". $val ."\";\n"; + } +?> diff --git a/1.4.0/dom/codeGen/1.4/tpl/tpl-constants-file.php b/1.4.0/dom/codeGen/1.4/tpl/tpl-constants-file.php new file mode 100644 index 0000000..8bfc456 --- /dev/null +++ b/1.4.0/dom/codeGen/1.4/tpl/tpl-constants-file.php @@ -0,0 +1,16 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +// Grab the file name and save the output +$_file = $_globals['prefix'] . "Constants.h"; +$_bytes = file_put_contents( ($_globals['target_dir'] . $_globals['dom_dir']. 'include/' . $_file), applyTemplate( 'CONSTANTS', $bag ) ); + +//if ( $_bytes > 0 ) { print "Wrote $_bytes bytes to file '$_file'\n"; } + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.4/tpl/tpl-constants.php b/1.4.0/dom/codeGen/1.4/tpl/tpl-constants.php new file mode 100644 index 0000000..199e849 --- /dev/null +++ b/1.4.0/dom/codeGen/1.4/tpl/tpl-constants.php @@ -0,0 +1,42 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +if ( $_globals['copyright'] ) { +print $_globals['copyright_text']; +} +?> +#ifndef __DOM_CONSTANTS_H__ +#define __DOM_CONSTANTS_H__ + +#include <dae/daeDomTypes.h> + +<?php + foreach ($bag as $name => $val ) { + if ( is_int($name) ) { + print $val; + continue; + } + print "extern DLLSPEC daeString ". $name .";\n"; + } + print "\n"; + + foreach ($_globals['elementTypes'] as $num => $val ) + { + print "extern DLLSPEC daeString COLLADA_TYPE_". getUniqueName($val, $_globals['elementTypes']) .";\n"; + } + print "\n"; + + foreach ($_globals['elementNames'] as $num => $val ) + { + print "extern DLLSPEC daeString COLLADA_ELEMENT_". getUniqueName($val, $_globals['elementNames']) .";\n"; + } +?> + +#endif //__DOM_CONSTANTS_H__ + diff --git a/1.4.0/dom/codeGen/1.4/tpl/tpl-cpp-body.php b/1.4.0/dom/codeGen/1.4/tpl/tpl-cpp-body.php new file mode 100644 index 0000000..757e953 --- /dev/null +++ b/1.4.0/dom/codeGen/1.4/tpl/tpl-cpp-body.php @@ -0,0 +1,25 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +if ( $_globals['copyright'] ) { +print $_globals['copyright_text']; +} +?> +#include <dae.h> +#include <<?= $_globals['meta_prefix'] ?>/daeDom.h> +#include <<?= $_globals['prefix'] ?>/<?= $_globals['prefix'] . ucfirst( $bag['element_name'] ) . ".h" ?>> +#include <<?= $_globals['meta_prefix'] ?>/daeMetaCMPolicy.h> +#include <<?= $_globals['meta_prefix'] ?>/daeMetaSequence.h> +#include <<?= $_globals['meta_prefix'] ?>/daeMetaChoice.h> +#include <<?= $_globals['meta_prefix'] ?>/daeMetaGroup.h> +#include <<?= $_globals['meta_prefix'] ?>/daeMetaAny.h> +#include <<?= $_globals['meta_prefix'] ?>/daeMetaElementAttribute.h> + +<?= applyTemplate( 'CPP_METHODS', $bag ) ?> +<?= applyTemplate( 'CPP_STATIC', $bag ) ?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.4/tpl/tpl-cpp-methods.php b/1.4.0/dom/codeGen/1.4/tpl/tpl-cpp-methods.php new file mode 100644 index 0000000..754df8c --- /dev/null +++ b/1.4.0/dom/codeGen/1.4/tpl/tpl-cpp-methods.php @@ -0,0 +1,462 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + + global $meta; + global $typemeta; + + $_context = $bag['context']; + for( $i=0; $i<count( $_context ); $i++ ) + { + $_context[$i] = $_globals['prefix'] . ucfirst( $_context[$i] ); + } + $scoped_element = implode( '::', $_context ); + + /*if ( $bag['has_any'] ) { + foreach ( $meta as $nm => $lm ) { + if ( !$lm['isAGroup'] && !$lm['isAComplexType'] && !$lm['abstract'] ) { + print "#include <". $_globals['prefix'] ."/". $_globals['prefix'] . ucfirst($nm).".h>\n"; + } + } + print "\n"; + }*/ + + if ( $scoped_element == "domCOLLADA" ) { + print "extern daeString COLLADA_VERSION;\n"; + print "extern daeString COLLADA_NAMESPACE;\n\n"; + } +?><?= $_globals['meta_prefix'] ?>ElementRef +<?= $scoped_element ?>::create(DAE& dae) +{ + <?= $scoped_element ?>Ref ref = new <?= $scoped_element ?>(dae); +<?php + if ( $bag['useXMLNS'] ) { + print "\tref->attrXmlns.setContainer( (". $scoped_element ."*)ref );\n"; + } + foreach( $bag['attributes'] as $attr_name => & $a_list ) { + if ( $a_list['type'] == 'xs:anyURI' || $a_list['type'] == 'URIFragmentType' ) { + print "\tref->attr". ucfirst($attr_name) .".setContainer( (". $scoped_element ."*)ref );\n"; + } + } + if ( $bag['content_type'] == 'xs:anyURI' || $bag['content_type'] == 'URIFragmentType' ) { + print "\tref->_value.setContainer( (". $scoped_element ."*)ref );\n"; + } + if ( $scoped_element == "domCOLLADA" ) { + print "\tref->_meta = dae.getMeta(domCOLLADA::ID());\n"; + print "\tref->setAttribute(\"version\", COLLADA_VERSION );\n"; + print "\tref->setAttribute(\"xmlns\", COLLADA_NAMESPACE );\n"; + print "\tref->_meta = NULL;\n"; + } +?> + return ref; +} + +<?php + if( $bag['complex_type'] && !$bag['isRestriction'] ) { + //print "element ". $bag['element_name'] ." is of base ". $bag['base_type'] ."\n"; + //import content model from type + $bag['elements'] = array_merge( $meta[$bag['base_type']]['elements'], $bag['elements'] ); + $bag['element_attrs'] = array_merge( $meta[$bag['base_type']]['element_attrs'], $bag['element_attrs'] ); + $bag['content_type'] = $meta[$bag['base_type']]['content_type']; + $bag['attributes'] = array_merge( $meta[$bag['base_type']]['attributes'], $bag['attributes'] ); + $tempArray = array(); + if ( count( $bag['content_model'] ) > 0 ) { + //we have an addition to the content model - need to add a starting sequence + $tempArray[] = array( 'name' => 0, 'minOccurs' => 1, 'maxOccurs' => 1 ); + } + $tempArray = array_merge( $tempArray, $meta[$bag['base_type']]['content_model'] ); + array_pop( $tempArray ); //remove the last END token + $tempArray = array_merge( $tempArray, $bag['content_model'] ); + if ( count( $bag['content_model'] ) > 0 ) { + //we have an addition to the content model - need to add a starting sequence + $tempArray[] = array( 'name' => 5, 'minOccurs' => 1, 'maxOccurs' => 1 ); + } + $bag['content_model'] = $tempArray; + } + + for( $i=0; $i<count( $bag['elements'] ); $i++ ) { + if ( isset( $meta[$bag['elements'][$i]] ) ) { + $cnt = count( $meta[$bag['elements'][$i]]['substitutableWith']); + for ( $c = 0; $c < $cnt; $c++ ) { + $subwith = $meta[$bag['elements'][$i]]['substitutableWith'][$c]; + print $prefix ."#include <". $_globals['prefix'] ."/". $_globals['prefix'] . ucfirst( $subwith ) .".h>\n"; + } + } + } +?> + +<?= $_globals['meta_prefix'] ?>MetaElement * +<?= $scoped_element ?>::registerElement(DAE& dae) +{ + <?= $_globals['meta_prefix'] ?>MetaElement* meta = dae.getMeta(ID()); + if ( meta != NULL ) return meta; + + meta = new daeMetaElement(dae); + dae.setMeta(ID(), *meta); + meta->setName( "<?= $bag['element_name'] ?>" ); + meta->registerClass(<?= $scoped_element ?>::create); + +<?php + if ( $bag['isAGroup'] ) { + print "\tmeta->setIsTransparent( true );\n"; + } + if ( $bag['abstract'] ) { + print "\tmeta->setIsAbstract( true );\n"; + } + if ( isset( $bag['parent_meta'] ) ) { + print "\tmeta->setIsInnerClass( true );\n"; + } + + if ( count( $bag['elements'] ) > 0 || $bag['has_any'] ) + { + print "\tdaeMetaCMPolicy *cm = NULL;\n"; + if ( !$bag['has_any'] ) { + print "\tdaeMetaElementAttribute *mea = NULL;\n"; + } + + $needsContents = false; + $cmTree = array(); + $currentCM = NULL; + $currentOrd = 0; + $level = 0; + $choiceNum = 0; + for( $i=0; $i<count( $bag['content_model'] ) - 1; $i++ ) + { + $cm = $bag['content_model'][$i]; + if ( $cm['maxOccurs'] == "unbounded" ) + { + $cm['maxOccurs'] = -1; + } + if ( is_int( $cm['name'] ) ) + { + if ( $cm['name'] == 0 ) //sequence + { + //if ( $level > 0 ) { + // $needsContents = true; + //} + + // !!!steveT Horrible hack here. For some reason the wrong value gets generated for + // the third parameter + if (strcmp($scoped_element, "domCamera::domOptics::domTechnique_common::domPerspective") == 0) + print "\tcm = new daeMetaSequence( meta, cm, 0, ". $cm['minOccurs'] .", ". $cm['maxOccurs'] ." );\n\n"; + else + print "\tcm = new daeMetaSequence( meta, cm, ". $currentOrd .", ". $cm['minOccurs'] .", ". $cm['maxOccurs'] ." );\n\n"; + + $level++; + $currentCM = array( 'cm' => $currentCM['cm'], 'ord' => $currentOrd ); + array_push( $cmTree, $currentCM ); + $currentCM = array( 'cm' => $cm, 'ord' => $currentOrd ); + $currentOrd = 0; + } + else if ( $cm['name'] == 1 ) //choice + { + print "\tcm = new daeMetaChoice( meta, cm, ". $choiceNum .", ". $currentOrd .", ". $cm['minOccurs'] .", ". $cm['maxOccurs'] ." );\n\n"; + $level++; + $needsContents = true; + $currentCM = array( 'cm' => $currentCM['cm'], 'ord' => $currentOrd ); + array_push( $cmTree, $currentCM ); + $currentCM = array( 'cm' => $cm, 'ord' => $currentOrd ); + $currentOrd = 0; + $choiceNum++; + } + else if ( $cm['name'] == 2 ) //group + { + $i++; //groups actually add two parts to the content model. The first is the group the second an element + $groupName = $bag['content_model'][$i]['name']; + $arrayOrNot = $bag['element_attrs'][ $groupName ]['maxOccurs']; + if ( $arrayOrNot == 'unbounded' || $arrayOrNot > 1 ) { + $arrayOrNot = true; + } + else { + $arrayOrNot = false; + } +?> + mea = new daeMetaElement<?= $arrayOrNot ? 'Array' : '' ?>Attribute( meta, cm, <?= $currentOrd ?>, <?= $cm['minOccurs'] ?>, <?= $cm['maxOccurs'] ?> ); + mea->setName( "<?= $groupName ?>" ); + mea->setOffset( daeOffsetOf(<?= $scoped_element ?>,elem<?= ucfirst( $groupName ) ?><?= $arrayOrNot ? '_array' : '' ?>) ); + mea->setElementType( <?= $_globals['prefix'] . ucfirst( $groupName ) ?>::registerElement(dae) ); + cm->appendChild( new daeMetaGroup( mea, meta, cm, <?= $currentOrd ?>, <?= $cm['minOccurs'] ?>, <?= $cm['maxOccurs'] ?> ) ); + +<?php + if ( $currentCM['cm']['name'] == 0 ) { + $currentOrd++; + } + } + else if ( $cm['name'] == 3 ) //all + { + //print "\tcm = new daeMetaAll( meta, cm, ". $cm['minOccurs'] .", ". $cm['maxOccurs'] ." );\n"; + $level++; + $needsContents = true; + $currentCM = array( 'cm' => $currentCM['cm'], 'ord' => $currentOrd ); + array_push( $cmTree, $currentCM ); + $currentCM = array( 'cm' => $cm, 'ord' => $currentOrd ); + $currentOrd = 0; + } + else if ( $cm['name'] == 4 ) //any + { + $level++; + print "\tcm = new daeMetaAny( meta, cm, ". $currentOrd .", ". $cm['minOccurs'] .", ". $cm['maxOccurs'] ." );\n\n"; + if ( $currentCM['cm']['name'] == 0 ) { + $currentOrd++; + } + } + else if ( $cm['name'] == 5 ) //end + { + $level--; + if ( $level > 0 ) + { +?> + cm->setMaxOrdinal( <?= ($currentOrd-1 >= 0)? $currentOrd-1 : 0 ?> ); + cm->getParent()->appendChild( cm ); + cm = cm->getParent(); + +<?php + } + //---------------------- + if ( $currentCM['cm']['name'] == 0 ) { + $tempMaxO = $currentCM['cm']['maxOccurs']; + $currentCM = array_pop( $cmTree ); + if ( $tempMaxO == -1 ) { + $currentOrd = $currentCM['ord'] + 3000; + } + else { + $currentOrd = $currentCM['ord'] + $tempMaxO*$currentOrd; + } + } + else { + $tempMaxO = $currentCM['cm']['maxOccurs']; + if ( $tempMaxO == -1 ) $tempMaxO = 3001; + $currentCM = array_pop( $cmTree ); + $currentOrd = $currentCM['ord'] + $tempMaxO; + } + } + } + else //got an element name + { + $arrayOrNot = $bag['element_attrs'][ $cm['name'] ]['maxOccurs']; + if ( $arrayOrNot == 'unbounded' || $arrayOrNot > 1 ) { + $arrayOrNot = true; + } + else { + $arrayOrNot = false; + } + $typeClass = $_globals['prefix'] . ucfirst( $cm['name'] ); + + if ( !in_array( $cm['name'], $bag['ref_elements'] ) && !$bag['complex_type'] ) { + $typeClass = $scoped_element ."::". $typeClass; + } + if ( isset( $bag['element_attrs'][ $cm['name'] ]['type'] ) && + isset( $meta[$bag['element_attrs'][ $cm['name'] ]['type']] ) ){ + + $typeClass = $_globals['prefix'] . ucfirst( $bag['element_attrs'][ $cm['name'] ]['type'] ); + } +?> + mea = new daeMetaElement<?= $arrayOrNot ? 'Array' : '' ?>Attribute( meta, cm, <?= $currentOrd ?>, <?= $cm['minOccurs'] ?>, <?= $cm['maxOccurs'] ?> ); + mea->setName( "<?= $cm['name'] ?>" ); + mea->setOffset( daeOffsetOf(<?= $scoped_element ?>,elem<?= ucfirst( $cm['name'] ) ?><?= $arrayOrNot ? '_array' : '' ?>) ); + mea->setElementType( <?= $typeClass ?>::registerElement(dae) ); + cm->appendChild( mea ); + +<?php + if ( isset( $meta[$cm['name']] ) ) { + $cnt = count( $meta[$cm['name']]['substitutableWith']); + for ( $c = 0; $c < $cnt; $c++ ) { + $subwith = $meta[$cm['name']]['substitutableWith'][$c]; +?> + mea = new daeMetaElement<?= $arrayOrNot ? 'Array' : '' ?>Attribute( meta, cm, <?= $currentOrd ?>, <?= $cm['minOccurs'] ?>, <?= $cm['maxOccurs'] ?> ); + mea->setName( "<?= $subwith ?>" ); + mea->setOffset( daeOffsetOf(<?= $scoped_element ?>,elem<?= ucfirst( $cm['name'] ) ?><?= $arrayOrNot ? '_array' : '' ?>) ); + mea->setElementType( <?= $_globals['prefix'] . ucfirst( $subwith ) ?>::registerElement(dae) ); + cm->appendChild( mea ); + +<?php + $needsContents = true; + } + } + if ( $currentCM['cm']['name'] == 0 ) { + $currentOrd++; + } + } + } +?> + cm->setMaxOrdinal( <?= ($currentOrd-1 >= 0)? $currentOrd-1 : 0 ?> ); + meta->setCMRoot( cm ); +<?php + + if ( $bag['has_any'] ) { + $needsContents = true; + print "\tmeta->setAllowsAny( true );\n"; + } + + // For elements that allow more than one type of sub-element, _contents keeps an order for those sub-elements + if ( $bag['hasChoice'] || $needsContents ) { +?> + // Ordered list of sub-elements + meta->addContents(daeOffsetOf(<?= $scoped_element ?>,_contents)); + meta->addContentsOrder(daeOffsetOf(<?= $scoped_element ?>,_contentsOrder)); + +<?php + if ( $choiceNum > 0 ) + { +?> + meta->addCMDataArray(daeOffsetOf(<?= $scoped_element ?>,_CMData), <?= $choiceNum ?>);<?php + } + } + } + + // TAKE CARE OF THE ENUM IF IT HAS ONE!! + if ( $bag['simple_type'] != NULL ) { + $typeMeta = $bag['simple_type']->getMeta(); + + if ( count( $typeMeta['enum'] ) > 0 && !$typeMeta['useConstStrings'] ) + { +?> + // ENUM: <?= ucfirst( $typeMeta['type'] ) ?>_type + daeAtomicType *type; + type = new daeEnumType; + type->_nameBindings.append("<?= ucfirst( $typeMeta['type'] ) ?>_type"); + ((daeEnumType*)type)->_strings = new daeStringRefArray; + ((daeEnumType*)type)->_values = new daeEnumArray; +<?php + foreach( $typeMeta['enum'] as $val ) + { +?> + ((daeEnumType*)type)->_strings->append("<?= $val ?>"); + ((daeEnumType*)type)->_values->append(<?= strtoupper($typeMeta['type']) . "_" . $val ?>); +<?php + } + print "\tdaeAtomicType::append( type );\n\n"; + } + } + + // NOTE: special casing any element with 'mixed' content model to ListOfInts type _value + $pre = ''; + if (($bag['content_type'] != '' || $bag['mixed']) && !$bag['abstract'] ) { +?> + // Add attribute: _value + { +<?php + $content_type = ( $bag['mixed'] ? 'ListOfInts' : $bag['content_type'] ); + if ( preg_match( "/xs\:/", $content_type ) ) { + $content_type = substr( $content_type, 3 ); + $pre = 'xs'; + } + //print "\t\tdaeMetaAttribute* ma = daeMetaAttribute::makeAttrForType(\"". ucfirst($content_type) ."\");\n"; + if ( (isset( $typemeta[$content_type] ) && $typemeta[$content_type]['isArray']) || $content_type == 'IDREFS' ) { + print "\t\tdaeMetaAttribute *ma = new daeMetaArrayAttribute;\n"; + } + else { + print "\t\tdaeMetaAttribute *ma = new daeMetaAttribute;\n"; + } +?> + ma->setName( "_value" ); +<?php + //if ( $bag['mixed'] ) { + // print "#ifdef POLYGONS_MIXED_CONTENT_MODEL_HOLES\n\t\tma->setType( daeAtomicType::get(\"ListOfStrings\"));\n"; + // print "#else\n\t\tma->setType( daeAtomicType::get(\"ListOfInts\"));\n#endif\n"; + //} + //else { + print "\t\tma->setType( dae.getAtomicTypes().get(\"". $pre. ucfirst($content_type) ."\"));\n"; + //} +?> + ma->setOffset( daeOffsetOf( <?= $scoped_element ?> , _value )); + ma->setContainer( meta ); + meta->appendAttribute(ma); + } +<?php + } + + if ( $bag['useXMLNS'] ) { + ?> + // Add attribute: xmlns + { + daeMetaAttribute* ma = new daeMetaAttribute; + ma->setName( "xmlns" ); + ma->setType( dae.getAtomicTypes().get("xsAnyURI")); + ma->setOffset( daeOffsetOf( <?= $scoped_element ?> , attrXmlns )); + ma->setContainer( meta ); + //ma->setIsRequired( true ); + meta->appendAttribute(ma); + } + <?php + } + + foreach( $bag['attributes'] as $attr_name => $attr_attrs ) + { + $_type = $attr_attrs['type']; + $printType; + if ( preg_match( "/xs\:/", $_type ) ) { + $_type = 'xs' . ucfirst( substr( $_type, 3 ) ); + $printType = $_type; + } + else { + $printType = ucfirst( $_type ); + } +?> + + // Add attribute: <?= $attr_name . "\n" ?> + { +<?php + /*print "\t//". $_type ." is set "; + if ( isset( $typemeta[$_type] ) ) print "true\n"; + else print "false\n"; + + print "\t//is array "; + if ( $typemeta[$_type]['isArray'] ) print "true\n"; + else print "false\n";*/ + + if ( isset( $typemeta[$_type] ) && $typemeta[$_type]['isArray'] ) { + print "\t\tdaeMetaAttribute *ma = new daeMetaArrayAttribute;\n"; + } + else { + print "\t\tdaeMetaAttribute *ma = new daeMetaAttribute;\n"; + } +?> + ma->setName( "<?= $attr_name ?>" ); + ma->setType( dae.getAtomicTypes().get("<?= $printType ?>")); + ma->setOffset( daeOffsetOf( <?= $scoped_element ?> , attr<?= ucfirst($attr_name) ?> )); + ma->setContainer( meta ); +<?php + if ( isset( $attr_attrs['default'] ) ) + { +?> ma->setDefaultString( "<?= $attr_attrs['default'] ?>"); +<?php + } + + if ( isset( $attr_attrs['use'] ) ) { + $required = $attr_attrs['use'] == 'required' ? 'true' : 'false'; + +?> ma->setIsRequired( <?= $required ?> ); +<?php + } +?> + meta->appendAttribute(ma); + } +<?php + } +?> + + meta->setElementSize(sizeof(<?= $scoped_element ?>)); + meta->validate(); + + return meta; +} + +<?php + $_keys = array_keys( $bag['inline_elements'] ); + if ( count( $_keys ) > 0 ) + { + foreach( $_keys as $_k ) + { + $inner = $bag['inline_elements'][ $_k ]; + if ( !$inner['complex_type'] || $inner['isRestriction'] || $inner['isExtension'] ) { + print applyTemplate( 'CPP_METHODS', $inner ); + } + } + } +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.4/tpl/tpl-cpp-static.php b/1.4.0/dom/codeGen/1.4/tpl/tpl-cpp-static.php new file mode 100644 index 0000000..80508b1 --- /dev/null +++ b/1.4.0/dom/codeGen/1.4/tpl/tpl-cpp-static.php @@ -0,0 +1,29 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + + $_context = $bag['context']; + for( $i=0; $i<count( $_context ); $i++ ) + { + $_context[$i] = $_globals['prefix'] . ucfirst( $_context[$i] );//. "_element"; + } +?> +<?php +//} + $keys = array_keys( $bag['inline_elements'] ); + if ( count( $keys ) > 0 ) + { + foreach( $keys as $k ) + { + $inner = $bag['inline_elements'][ $k ]; + if ( !$inner['complex_type'] || $inner['isRestriction'] || $inner['isExtension'] ) { + print applyTemplate( 'CPP_STATIC', $inner ); + } + } + } +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.4/tpl/tpl-cpp.php b/1.4.0/dom/codeGen/1.4/tpl/tpl-cpp.php new file mode 100644 index 0000000..49c3b42 --- /dev/null +++ b/1.4.0/dom/codeGen/1.4/tpl/tpl-cpp.php @@ -0,0 +1,16 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +// Grab the file name and save the output +$_file = $_globals['prefix'] . ucfirst( $bag['element_name'] ) . ".cpp"; +$_bytes = file_put_contents( ($_globals['target_dir'] . $_globals['dom_dir'] . 'src/' . $_file), applyTemplate( 'CPP', $bag ) ); + +//if ( $_bytes > 0 ) { print "Wrote $_bytes bytes to file '$_file'\n"; } + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.4/tpl/tpl-dot-h.php b/1.4.0/dom/codeGen/1.4/tpl/tpl-dot-h.php new file mode 100644 index 0000000..6d14e57 --- /dev/null +++ b/1.4.0/dom/codeGen/1.4/tpl/tpl-dot-h.php @@ -0,0 +1,28 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +if ( $_globals['copyright'] ) { +print $_globals['copyright_text']; +} +?>#ifndef __<?= $_globals['prefix'] . ucfirst( $bag['element_name'] ) ?>_h__ +#define __<?= $_globals['prefix'] . ucfirst( $bag['element_name'] ) ?>_h__ + +#include <dae/daeDocument.h> +#include <<?= $_globals['prefix'] . '/' . $_globals['prefix'] ?>Types.h> +#include <<?= $_globals['prefix'] . '/' . $_globals['prefix'] ?>Elements.h> + +<?php +global $includeList; +$includeList = array(); +print applyTemplate( 'INCLUDES', $bag ) ?> +class DAE; + +<?= applyTemplate( 'CLASS', $bag ) ?> + +#endif diff --git a/1.4.0/dom/codeGen/1.4/tpl/tpl-doxygen.php b/1.4.0/dom/codeGen/1.4/tpl/tpl-doxygen.php new file mode 100644 index 0000000..30a6d6d --- /dev/null +++ b/1.4.0/dom/codeGen/1.4/tpl/tpl-doxygen.php @@ -0,0 +1,38 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +global $indent; +// Add doxygen formatted comments + +print $indent ."/**\n"; + +//$_local_doc = $bag['documentation'][ $_globals['language'] ]; +$_local_doc = str_replace( "\n", " ", $bag ); +$_local_doc = str_replace( "\t", "", $_local_doc ); +while( strlen( $_local_doc ) > 0 ) +{ + if ( preg_match( "/(.{0,70}[^\s]*)(\s*)/", $_local_doc, $matches ) ) + { + // Print blocks of 70 chars thru the next word + print $indent ." * " . $matches[1] . "\n"; + + // Account for any newlines + /*$n_newlines = preg_match_all( "/\n/", $matches[2], $buf ); + if ( $n_newlines > 0 ) + { + for( $i=0; $i<$n_newlines; $i++ ) { print " * \n"; } + }*/ + + // Find more lines... + $_local_doc = substr( $_local_doc, strlen( $matches[0] ) ); + } +} + +print $indent ." */\n"; +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.4/tpl/tpl-elements-file.php b/1.4.0/dom/codeGen/1.4/tpl/tpl-elements-file.php new file mode 100644 index 0000000..4e5694d --- /dev/null +++ b/1.4.0/dom/codeGen/1.4/tpl/tpl-elements-file.php @@ -0,0 +1,16 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +// Grab the file name and save the output +$_file = $_globals['prefix'] . "Elements.h"; +$_bytes = file_put_contents( ($_globals['target_dir'] . $_globals['dom_dir'] . 'include/' . $_file), applyTemplate( 'ELEMENTS', $bag ) ); + +//if ( $_bytes > 0 ) { print "Wrote $_bytes bytes to file '$_file'\n"; } + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.4/tpl/tpl-elements.php b/1.4.0/dom/codeGen/1.4/tpl/tpl-elements.php new file mode 100644 index 0000000..f16d2af --- /dev/null +++ b/1.4.0/dom/codeGen/1.4/tpl/tpl-elements.php @@ -0,0 +1,31 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +if ( $_globals['copyright'] ) { +print $_globals['copyright_text']; +} +?> +#ifndef __DOM_ELEMENTS_H__ +#define __DOM_ELEMENTS_H__ + +#include <<?= $_globals['prefix'] ?>/<?= $_globals['prefix'] ?>Types.h> + +<?php +//Base elements +foreach( $bag as $name => $meta ) { + $full_element_name = $_globals['prefix'] . ucfirst( $name ); + print "class " . $full_element_name . ";\n\n"; + print "typedef daeSmartRef<". $full_element_name ."> ". $full_element_name ."Ref;\n"; + print "typedef daeTArray<". $full_element_name ."Ref> ". $full_element_name ."_Array;\n\n"; +} + +?> + +#endif //__DOM_ELEMENTS_H__ + diff --git a/1.4.0/dom/codeGen/1.4/tpl/tpl-header.php b/1.4.0/dom/codeGen/1.4/tpl/tpl-header.php new file mode 100644 index 0000000..07dad80 --- /dev/null +++ b/1.4.0/dom/codeGen/1.4/tpl/tpl-header.php @@ -0,0 +1,16 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +// Grab the file name and save the output +$_file = $_globals['prefix'] . ucfirst( $bag['element_name'] ) . ".h"; +$_bytes = file_put_contents( ($_globals['target_dir'] . $_globals['dom_dir'] . 'include/' . $_file), applyTemplate( 'HEADER', $bag ) ); + +//if ( $_bytes > 0 ) { print "dom/" . $_globals['prefix'] . ucfirst( $bag['element_name'] ) . ".obj "; } + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.4/tpl/tpl-include-list.php b/1.4.0/dom/codeGen/1.4/tpl/tpl-include-list.php new file mode 100644 index 0000000..f09c278 --- /dev/null +++ b/1.4.0/dom/codeGen/1.4/tpl/tpl-include-list.php @@ -0,0 +1,13 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ +?>/* --- DO NOT REMOVE THIS LINE --- SNIP_SDK_COPYRIGHT_C_BEGIN + * --- DO NOT REMOVE THIS LINE --- SNIP_SDK_COPYRIGHT_C_END */ + +<?= implode( "\n", $_globals['include_list'] ) ?> + diff --git a/1.4.0/dom/codeGen/1.4/tpl/tpl-includes.php b/1.4.0/dom/codeGen/1.4/tpl/tpl-includes.php new file mode 100644 index 0000000..be4be90 --- /dev/null +++ b/1.4.0/dom/codeGen/1.4/tpl/tpl-includes.php @@ -0,0 +1,32 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + + // INCLUDES + $inc = array(); + global $includeList; + for( $i=0; $i<count( $bag['ref_elements'] ); $i++ ) + { + if ( !in_array( $_globals['prefix'] . ucfirst( $bag['ref_elements'][$i] ), $includeList ) ) { + $inc[] = "#include <" . $_globals['prefix'] . "/" . $_globals['prefix'] . ucfirst( $bag['ref_elements'][$i] ) . ".h>"; + $includeList[] = $_globals['prefix'] . ucfirst( $bag['ref_elements'][$i] ); + } + } + if ( count( $inc ) ) { //only print if you have to include something + print implode( "\n", $inc ) . "\n"; + } + + $keys = array_keys( $bag['inline_elements'] ); + if ( count( $keys ) > 0 ) + { + foreach( $keys as $k ) + { + print applyTemplate( 'INCLUDES', $bag['inline_elements'][ $k ] ); + } + } +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.4/tpl/tpl-types-cpp-file.php b/1.4.0/dom/codeGen/1.4/tpl/tpl-types-cpp-file.php new file mode 100644 index 0000000..16f15c6 --- /dev/null +++ b/1.4.0/dom/codeGen/1.4/tpl/tpl-types-cpp-file.php @@ -0,0 +1,16 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +// Grab the file name and save the output +$_file = $_globals['prefix'] . "Types.cpp"; +$_bytes = file_put_contents( ($_globals['target_dir'] . $_globals['dom_dir'] . 'src/' . $_file), applyTemplate( 'TYPES_CPP', $bag ) ); + +//if ( $_bytes > 0 ) { print "Wrote $_bytes bytes to file '$_file'\n"; } + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.4/tpl/tpl-types-cpp.php b/1.4.0/dom/codeGen/1.4/tpl/tpl-types-cpp.php new file mode 100644 index 0000000..b6199d2 --- /dev/null +++ b/1.4.0/dom/codeGen/1.4/tpl/tpl-types-cpp.php @@ -0,0 +1,136 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +if ( $_globals['copyright'] ) { +print $_globals['copyright_text']; +} +?> +#include <dae.h> +#include <<?= $_globals['prefix'] . '/' . $_globals['prefix'] ?>Types.h> +#include <dae/daeDom.h> +#include <dom/domCOLLADA.h> + +<?php + +foreach( $bag as $type => $meta ) +{ + if ( $meta['isComplex'] ) { + ?>#include <<?= $_globals['prefix'] . '/' . $_globals['prefix'] . ucfirst( $type ) ?>.h> +<?php + } +} + +?> + +void registerDomTypes(DAE& dae) +{ + daeAtomicType* type = NULL; + daeAtomicTypeList& atomicTypes = dae.getAtomicTypes(); + +<?php + +foreach( $bag as $type => $meta ) +{ + if ( count( $meta['enum'] ) > 0 && !$meta['useConstStrings'] ) + {?> + // ENUM: <?= ucfirst( $type ) ?> + + type = new daeEnumType(dae); + type->_nameBindings.append("<?= ucfirst( $type ) ?>"); + ((daeEnumType*)type)->_strings = new daeStringRefArray; + ((daeEnumType*)type)->_values = new daeEnumArray; +<?php + foreach( $meta['enum'] as $val ) + {?> + ((daeEnumType*)type)->_strings->append("<?= $val ?>"); +<?php $val = str_replace( '.', '_', $val ); ?> + ((daeEnumType*)type)->_values->append(<?= strtoupper($type) . "_" . $val ?>); +<?php + } + print "\tatomicTypes.append( type );\n\n"; + } + elseif ( $meta['isComplex'] ) { + ?> + // COMPLEX TYPE: <?= ucfirst( $type ) ?> + + type = new daeElementRefType(dae); + type->_nameBindings.append("<?= ucfirst( $type ) ?>"); + atomicTypes.append( type ); + +<?php + } + /*else if ( $meta['union_type'] ) { //union type + ?> + // ENUM: <?= ucfirst( $type ) ?> + + type = new daeEnumType; + type->_nameBindings.append("<?= ucfirst( $type ) ?>"); + ((daeEnumType*)type)->_strings = new daeStringRefArray; + ((daeEnumType*)type)->_values = new daeEnumArray; +<?php + $types = explode( ' ', $meta['union_members'] ); + foreach ( $types as $typeName ) { + if ( isset( $bag[$typeName] ) && count($bag[$typeName]['enum']) > 0 ) { + foreach( $bag[$typeName]['enum'] as $val ) + {?> + ((daeEnumType*)type)->_strings->append("<?= $val ?>"); +<?php $val = str_replace( '.', '_', $val ); ?> + ((daeEnumType*)type)->_values->append(<?= strtoupper($type) . "_" . $val ?>); +<?php + } + } + } + print "\tatomicTypes.append( type );\n\n"; + } */ + else if ( !$meta['useConstStrings'] ) { //standard typedef + $base = strlen( $meta['base'] ) > 0 ? $meta['base'] : $meta['listType']; + if ( preg_match( "/xs\:/", $base ) ) { + $base = 'xs' . ucfirst( substr( $base, 3 ) ); + } + else { + $base = ucfirst( $base ); + } + ?> + // TYPEDEF: <?= ucfirst( $type ) ?> + //check if this type has an existing base +<?php + //special casing URIFragmentType to be a xsURI for automatic resolution + if ( $type == 'URIFragmentType' ) { + print "\ttype = atomicTypes.get(\"xsAnyURI\");\n"; + } + else { + print "\ttype = atomicTypes.get(\"". $base ."\");\n"; + } +?> + if ( type == NULL ) { //register as a raw type + type = new daeRawRefType(dae); + type->_nameBindings.append("<?= ucfirst( $type ) ?>"); + atomicTypes.append( type ); + } + else { //add binding to existing type + type->_nameBindings.append("<?= ucfirst( $type ) ?>"); + } + +<?php + } +} +?> +} + +daeMetaElement* registerDomElements(DAE& dae) +{ + daeMetaElement* meta = domCOLLADA::registerElement(dae); + // Enable tracking of top level object by default + meta->setIsTrackableForQueries(true); + return meta; +} + +daeInt DLLSPEC colladaTypeCount() { + return <?php /* +1 for <any> */ print ($_globals['typeID']+1); ?>; +} diff --git a/1.4.0/dom/codeGen/1.4/tpl/tpl-types-header-file.php b/1.4.0/dom/codeGen/1.4/tpl/tpl-types-header-file.php new file mode 100644 index 0000000..e635bae --- /dev/null +++ b/1.4.0/dom/codeGen/1.4/tpl/tpl-types-header-file.php @@ -0,0 +1,16 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +// Grab the file name and save the output +$_file = $_globals['prefix'] . "Types.h"; +$_bytes = file_put_contents( ($_globals['target_dir'] . $_globals['dom_dir'] . 'include/' . $_file), applyTemplate( 'TYPES_HEADER', $bag ) ); + +//if ( $_bytes > 0 ) { print "Wrote $_bytes bytes to file '$_file'\n"; } + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.4/tpl/tpl-types-header.php b/1.4.0/dom/codeGen/1.4/tpl/tpl-types-header.php new file mode 100644 index 0000000..52c7e57 --- /dev/null +++ b/1.4.0/dom/codeGen/1.4/tpl/tpl-types-header.php @@ -0,0 +1,172 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +if ( $_globals['copyright'] ) { +print $_globals['copyright_text']; +} +?> +#ifndef __DOM_TYPES_H__ +#define __DOM_TYPES_H__ + +#include <dae/daeDomTypes.h> + +<?php +//BASIC TYPES +foreach( $bag as $type => $meta ) +{ + if ( count( $meta['enum'] ) == 0 && !$meta['isComplex'] ) { + if ( strlen( $meta['base'] ) > 0 ) { //has a base type + if ( preg_match( "/xs\:/", $meta['base'] ) ) { + $base = substr( $meta['base'], 3 ); + $pre = 'xs'; + } + else { + $base = $meta['base']; + $pre = $_globals['prefix']; + } + if ( isset( $meta['documentation']['en'] ) ) { + print applyTemplate( 'DOXYGEN', $meta['documentation']['en'] ); + } + //special casing URIFragmentType to be a xsURI for automatic resolution + if ( $type == 'URIFragmentType' ) { + print "typedef xsAnyURI\t\tdomURIFragmentType;\n"; + } + else { + print "typedef " . $pre . ucfirst($base) . "\t\t" . $_globals['prefix'] . ucfirst( $type ) . ";\n"; + } + } + elseif ( strlen( $meta['listType'] ) > 0 ) { //is a list type + if ( isset( $meta['documentation']['en'] ) ) { + print applyTemplate( 'DOXYGEN', $meta['documentation']['en'] ); + } + if ( preg_match( "/xs\:/", $meta['listType'] ) ) { + $lt = substr( $meta['listType'], 3 ); + print "typedef xs" . ucfirst($lt) . "Array\t\t" . $_globals['prefix'] . ucfirst( $type ) . ";\n"; + } + else { + $lt = $meta['listType']; + print "typedef daeTArray<" . $_globals['prefix'] . ucfirst($lt) . ">\t\t" . $_globals['prefix'] . ucfirst( $type ) . ";\n"; + } + } + } +} + +print "\n"; + +//ENUMS +foreach( $bag as $type => $meta ) +{ + if ( count( $meta['enum'] ) > 0 ) + { + if ( !$meta['useConstStrings'] ) { + //Decided to name mangle the enum constants so they are more descriptive and avoid collisions + if ( isset( $meta['documentation']['en'] ) ) { + print applyTemplate( 'DOXYGEN', $meta['documentation']['en'] ); + } + print "enum " . $_globals['prefix'] . ucfirst( $type ) . " {\n"; + for( $i = 0; $i < count( $meta['enum'] ); $i++ ) { + $val = $meta['enum'][$i]; + $val = str_replace( '.', '_', $val ); + print "\t" . strtoupper( $type ) . "_" . $val; + if ( isset( $meta['enum_value'][$i] ) ) { + print " = ". $meta['enum_value'][$i]; + } + //else if ($i==0) { + // print " = 1"; + //} + print ","; + if ( isset( $meta['enum_documentation'][$i] ) ) { + print "\t\t/**< ". $meta['enum_documentation'][$i] ." */"; + } + print "\n"; + } + $cnt = count($meta['enum']); + //if ( !isset($meta['enum_value'][0]) ) { + // $cnt++; + //} + print "\t". strtoupper( $type ) . "_COUNT = ". $cnt; + print "\n};\n\n"; + } + else { + for( $i = 0; $i < count( $meta['enum'] ); $i++ ) { + if ( isset( $meta['enum_documentation'][$i] ) ) { + $_globals['constStrings'][] = "/**\n * ". $meta['enum_documentation'][$i] ."\n */\n"; + } + $conststrnm = strtoupper( $type ) . "_" . $meta['enum'][$i]; + $conststr = "\"". $meta['enum'][$i] ."\";\n"; + $_globals['constStrings'][$conststrnm] = $conststr; + } + $_globals['constStrings'][] = "\n"; + } + } +} + +//UNIONS +foreach( $bag as $type => & $meta ) +{ + if ( $meta['union_type'] ) + { + if ( isset( $meta['documentation']['en'] ) ) { + print applyTemplate( 'DOXYGEN', $meta['documentation']['en'] ); + } + print "enum " . $_globals['prefix'] . ucfirst( $type ) . " {\n"; + + //tokenize memberTypes string + $types = explode( ' ', $meta['union_members'] ); + //look up the members + $cnt = 1; + foreach ( $types as $typeName ) { + if ( isset( $bag[$typeName] ) && count($bag[$typeName]['enum']) > 0 ) { + //print all of their enum children + for( $i = 0; $i < count( $bag[$typeName]['enum'] ); $i++ ) { + $val = $bag[$typeName]['enum'][$i]; + $val = str_replace( '.', '_', $val ); + if ( in_array( $val, $meta['enum'] ) ) { + continue; + } + $meta['enum'][] = $val; + print "\t" . strtoupper( $type ) . "_" . $val; + if ( isset( $bag[$typeName]['enum_value'][$i] ) ) { + print " = ". $bag[$typeName]['enum_value'][$i]; + } + else if ($i==0) { + print " = 1"; + } + print ","; + if ( isset( $bag[$typeName]['enum_documentation'][$i] ) ) { + print "\t\t/**< ". $bag[$typeName]['enum_documentation'][$i] ." */"; + } + print "\n"; + $cnt++; + } + } + } + print "\t". strtoupper( $type ) . "_COUNT = ". $cnt; + print "\n};\n\n"; + } +} + +?> +//Element Type Enum +namespace COLLADA_TYPE +{ + const int + NO_TYPE = 0, + ANY = 1<?php + foreach( $_globals['elementTypes'] as $num => $val ) + print ",\n\t\t". getUniqueName($val, $_globals['elementTypes']) ." = ". ($num+2); + print ";" +?> + +} + +// Returns the total number of schema types/dom* classes +daeInt DLLSPEC colladaTypeCount(); + +#endif diff --git a/1.4.0/dom/codeGen/1.5/gen.php b/1.4.0/dom/codeGen/1.5/gen.php new file mode 100644 index 0000000..3cd8a5d --- /dev/null +++ b/1.4.0/dom/codeGen/1.5/gen.php @@ -0,0 +1,158 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +// COMMAND LINE: bin/php.exe gen.php collada.xsd [minimal] +// Note: must be run from home directory of code generator (i.e. where gen.php lives) + +ini_set("memory_limit", "256M"); + +if ( file_exists( $argv[1] ) ) { $collada_file = $argv[1]; } +else +{ + die( "Can't find COLLADA file '" . $argv[1] . "'\n" ); +} + + +require_once( 'src/SchemaParser.php' ); +require_once( 'om/object-model.php' ); +require_once( 'tpl/template-engine.php' ); + +// Returns either a capitalized or non-capitalized version of the name, thus helping us +// avoid name clashes. For example, say we have an element called 'rgb' and an element +// called 'RGB'. They're both going to map to the name constant 'COLLADA_ELEMENT_RGB'. +// Instead, use COLLADA_ELEMENT_rgb for the 'rgb' element. +function getUniqueName($name, $array) { + $uniqueName = strtoupper($name); + if (array_search($uniqueName, $array) !== FALSE) { + $uniqueName = $name; + } + return $uniqueName; +} + + +if ( preg_match( "/min/i", $argv[2] ) || preg_match( "/min/i", $argv[3] ) ) { + $_globals['full_code'] = false; +} +if ( preg_match( "/cprt/i", $argv[2] ) || preg_match( "/cprt/i", $argv[3] ) ) { + $_globals['copyright'] = true; +} + +$_globals['accessorsAndMutators'] = true; + +$p = new SchemaParser(); +$p->parse( $collada_file ); + + +initGen( $collada_file ); + + +$pop = $p->root_elements[0]; + +//Grab the collada version number +$_globals['constStrings']['COLLADA_VERSION'] = "\"". $pop->getAttribute('version') . "\";\n"; +//Grab the collada namespace +$_globals['constStrings']['COLLADA_NAMESPACE'] = "\"". $pop->getAttribute('xmlns') . "\";\n\n"; + +// Grab simple types and collect meta-data for code-gen +$t_list = $pop->getElementsByType( 'xsSimpleType' ); + + +$typemeta = array(); + +for( $i=0; $i<count( $t_list ); $i++ ) +{ + $local_meta = & $t_list[$i]->generate(); + $typemeta[ $local_meta['type'] ] = & $local_meta; + //print "Type: ". $local_meta['type'] ." created\n"; +} + +function propogateArrayTypes( &$lmeta ) { + global $typemeta; + if ( $lmeta['isArray'] ) { + return; + } + if( isset( $typemeta[$lmeta['base']] ) ) { + propogateArrayTypes( $typemeta[$lmeta['base']] ); + $lmeta['isArray'] = $typemeta[$lmeta['base']]['isArray']; + } + //print $lmeta['type'] ." isArray = ". $lmeta['isArray'] ."\n"; +} +foreach( $typemeta as $k => &$local_meta ) { + propogateArrayTypes( $local_meta ); +} + +//Grab global complex types and make them available for all who need them + +$_globals['complex_types'] = $pop->getElementsByType( 'xsComplexType' ); + +//generate type meta data +//print applyTemplate( 'TYPES_HEADER_FILE', $typemeta ); +//print applyTemplate( 'TYPES_CPP_FILE', $typemeta ); + +$element_context = array(); +$meta = array(); + +print "COMPLEX TYPES\n"; +for( $i=0; $i<count( $_globals['complex_types'] ); $i++ ) +{ + $local_meta = & $_globals['complex_types'][$i]->generate( $element_context, $_globals['global_elements'] ); + $meta[ $local_meta['element_name'] ] = & $local_meta; +} + +//collect element meta-data for code-gen + +//Grab global groups and make them available for all who need them +$_globals['groups'] = $pop->getElementsByType( 'xsGroup' ); +//collect meta-data for code-gen +print "GROUPS\n"; +for( $i=0; $i<count( $_globals['groups'] ); $i++ ) +{ + $local_meta = & $_globals['groups'][$i]->generate( $element_context, $_globals['global_elements'] ); + $meta[ $local_meta['element_name'] ] = & $local_meta; +} + +// Grab global elements and collect meta-data for code-gen +$e_list = $pop->getElementsByType( 'xsElement' ); + +print "ELEMENTS\n"; + +for( $i=0; $i<count( $e_list ); $i++ ) +{ + $local_meta = & $e_list[$i]->generate( $element_context, $_globals['global_elements'] ); + $meta[ $local_meta['element_name'] ] = & $local_meta; +} + +//propogate the substitutableWith lists and attributes inherited by type +foreach( $meta as $k => &$local_meta ) { + if ( $local_meta['substitution_group'] != '' ) { + $meta[$local_meta['substitution_group']]['substitutableWith'][] = $k; + //$meta[$local_meta['substitution_group']]['ref_elements'][] = $k; + //print $local_meta['substitution_group'] ." sub with ". $k ."\n"; + } +} + +$indentNum = 0; +// Generate header files +$includeList = array(); +foreach( $meta as $k => &$local_meta ) +{ + // Generate the dom + print applyTemplate( 'HEADER_FILE', $local_meta ); + print applyTemplate( 'CPP_FILE', $local_meta ); +} + +print applyTemplate( 'TYPES_HEADER_FILE', $typemeta ); +print applyTemplate( 'TYPES_CPP_FILE', $typemeta ); + +print applyTemplate( 'ELEMENTS_FILE', $meta ); +print applyTemplate( 'CONSTANTS_FILE', $_globals['constStrings'] ); +print applyTemplate( 'CONSTANTS_CPP_FILE', $_globals['constStrings'] ); +cleanupGen(); + +?> diff --git a/1.4.0/dom/codeGen/1.5/om/base-types.php b/1.4.0/dom/codeGen/1.5/om/base-types.php new file mode 100644 index 0000000..75cd110 --- /dev/null +++ b/1.4.0/dom/codeGen/1.5/om/base-types.php @@ -0,0 +1,187 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +class _type +{ + var $type = array(); + + function _type() + { + $this->type[] = "MotherOfAllTypes"; + } + + function isOfType( $type ) + { + return( $type == $this->type[ count( $this->type ) - 1 ] ); + } + + function getType() + { + $type = "NULL"; + if ( count( $this->type ) > 0 ) { $type = $this->type[ 0 ]; } + return $type; + } + + function isAncestor( $type ) + { + return in_array( $type, $this->type ); + } +} + +class _typedData extends _type +{ + var $data; + + var $attributeMeta = array(); + var $attributes = array(); + + function _typedData() + { + $this->type[] = "TypedData"; + parent::_type(); + } + + function _addAttribute( $name, $meta ) + { + $this->attributeMeta[ $name ] = $meta; + } + + function setAttribute( $name, $value ) + { + // Make sure we know about the attribute before setting it + if ( isset( $this->attributeMeta[ $name ] ) ) + { + $this->attributes[ $name ] = $value; + } + } + + function getAttribute( $name ) + { + $val = ""; + if ( isset( $this->attributeMeta[ $name ] ) && isset( $this->attributes[ $name ] ) ) { + $val = $this->attributes[ $name ]; + } + return $val; + } + + function & getAttributes() + { + return $this->attributes; + } + + function set( & $buffer ) + { + $this->data = $buffer; + } + + function append( & $buffer ) + { + $this->data .= $buffer; + } + + function get() + { + return $this->data; + } +} + +class _elementSet extends _typedData +{ + var $elementMeta = array(); + var $elements = array(); + + function _elementSet() + { + $this->_addAttribute( 'minOccurs', array( 'type' => 'xs:integer' ) ); + $this->setAttribute( 'minOccurs', '1' ); + $this->_addAttribute( 'maxOccurs', array( 'type' => 'xs:integer' ) ); + $this->setAttribute( 'maxOccurs', '1' ); + + $this->type[] = "ElementSet"; + parent::_typedData(); + } + + function _addElement( $name, $attrs ) + { + $this->elementMeta[ $name ] = $attrs; + } + + function addElement( & $e ) + { + if ( in_array( $e->getType(), array_keys( $this->elementMeta ) ) ) + { + $this->elements[] = & $e; + } else + { + print "Invalid element ". $e->getType() ."in ". $this->getType() ."\n"; + $this->log( "WARN: " . $e->getType() . " not a valid member of " . $this->getType() ); + } + } + + function & getElements() + { + return $this->elements; + } + + function & getElementsByType( $type ) + { + $list = array(); + for( $i=0; $i<count( $this->elements ); $i++ ) + { + if ( $this->elements[$i]->getType() == $type ) + { + $list[] = & $this->elements[$i]; + } + } + return $list; + } + + function setElement( $name, & $value ) + { + $this->elements[ $name ] = $value; + } + + function exists( $name ) + { + return isset( $this->elements[ $name ] ); + } + + function delete( $name ) + { + unset( $this->elements[ $name ] ); + } + + function _delete( $name ) + { + $this->delete( $name ); + unset( $this->elementMeta[ $name ] ); + } + + function getCount() + { + return count( $this->elements ); + } + + function findTypeByName( $name ) + { + for ( $i = 0; $i < count( $GLOBALS['_globals']['complex_types'] ); $i++ ) { + if ( !strcmp($name, $GLOBALS['_globals']['complex_types'][$i]->getAttribute('name') ) ) { + return $GLOBALS['_globals']['complex_types'][$i]; + } + } + for ( $i = 0; $i < count( $GLOBALS['_globals']['simple_types'] ); $i++ ) { + if ( !strcmp($name, $GLOBALS['_globals']['simple_types'][$i]->getAttribute('name') ) ) { + return $GLOBALS['_globals']['simple_types'][$i]; + } + } + } + +} + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.5/om/object-model.php b/1.4.0/dom/codeGen/1.5/om/object-model.php new file mode 100644 index 0000000..271c04b --- /dev/null +++ b/1.4.0/dom/codeGen/1.5/om/object-model.php @@ -0,0 +1,43 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +require_once( 'om/base-types.php' ); + +require_once( 'om/xsAll.php' ); +require_once( 'om/xsAnnotation.php' ); +require_once( 'om/xsAny.php' ); +require_once( 'om/xsAttribute.php' ); +require_once( 'om/xsChoice.php' ); +require_once( 'om/xsComplexContent.php' ); +require_once( 'om/xsComplexType.php' ); +require_once( 'om/xsAll.php' ); +require_once( 'om/xsDocumentation.php' ); +require_once( 'om/xsAppinfo.php' ); +require_once( 'om/xsElement.php' ); +require_once( 'om/xsEnumeration.php' ); +require_once( 'om/xsExtension.php' ); +require_once( 'om/xsGroup.php' ); +require_once( 'om/xsList.php' ); +require_once( 'om/xsMaxLength.php' ); +require_once( 'om/xsMaxExclusive.php' ); +require_once( 'om/xsMaxInclusive.php' ); +require_once( 'om/xsMinLength.php' ); +require_once( 'om/xsMinExclusive.php' ); +require_once( 'om/xsMinInclusive.php' ); +require_once( 'om/xsPattern.php' ); +require_once( 'om/xsRestriction.php' ); +require_once( 'om/xsSchema.php' ); +require_once( 'om/xsSequence.php' ); +require_once( 'om/xsSimpleContent.php' ); +require_once( 'om/xsSimpleType.php' ); +require_once( 'om/xsUnion.php' ); +require_once( 'om/xsWhiteSpace.php' ); +require_once( 'om/xsImport.php' ); + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.5/om/xsAll.php b/1.4.0/dom/codeGen/1.5/om/xsAll.php new file mode 100644 index 0000000..bbe1b45 --- /dev/null +++ b/1.4.0/dom/codeGen/1.5/om/xsAll.php @@ -0,0 +1,27 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +class xsAll extends _elementSet +{ + function xsAll() + { + $this->_addElement( 'xsElement', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsAttribute', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + + $this->type[] = "xsAll"; + parent::_elementSet(); + } + + function addAllElement( & $e ) + { + $this->addElement( $e ); + } +} + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.5/om/xsAnnotation.php b/1.4.0/dom/codeGen/1.5/om/xsAnnotation.php new file mode 100644 index 0000000..b6fbd4b --- /dev/null +++ b/1.4.0/dom/codeGen/1.5/om/xsAnnotation.php @@ -0,0 +1,31 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +class xsAnnotation extends _elementSet +{ + function xsAnnotation() + { + $this->_addElement( 'xsDocumentation', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsAppinfo', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + + $this->type[] = "xsAnnotation"; + parent::_elementSet(); + + // Set bounds on number of elements allowable in annotation element + $this->setAttribute( 'minOccurs', '0' ); + $this->setAttribute( 'maxOccurs', 'unbounded' ); + } + + function addAnnotationElement( & $e ) + { + $this->addElement( $e ); + } +} + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.5/om/xsAny.php b/1.4.0/dom/codeGen/1.5/om/xsAny.php new file mode 100644 index 0000000..3a35831 --- /dev/null +++ b/1.4.0/dom/codeGen/1.5/om/xsAny.php @@ -0,0 +1,27 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +class xsAny extends _typedData +{ + function xsAny() + { + $this->_addAttribute( 'namespace', array( 'type' => 'xs:anyURI' ) ); + $this->_addAttribute( 'processContents', array( 'type' => 'xs:string' ) ); + + $this->_addAttribute( 'minOccurs', array( 'type' => 'xs:integer' ) ); + $this->setAttribute( 'minOccurs', '1' ); + $this->_addAttribute( 'maxOccurs', array( 'type' => 'xs:integer' ) ); + $this->setAttribute( 'maxOccurs', '1' ); + + $this->type[] = 'xsAny'; + parent::_typedData(); + } +} + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.5/om/xsAppinfo.php b/1.4.0/dom/codeGen/1.5/om/xsAppinfo.php new file mode 100644 index 0000000..625296b --- /dev/null +++ b/1.4.0/dom/codeGen/1.5/om/xsAppinfo.php @@ -0,0 +1,19 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +class xsAppinfo extends _typedData +{ + function xsAppinfo() + { + $this->type[] = "xsAppinfo"; + parent::_typedData(); + } +} + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.5/om/xsAttribute.php b/1.4.0/dom/codeGen/1.5/om/xsAttribute.php new file mode 100644 index 0000000..f8aa845 --- /dev/null +++ b/1.4.0/dom/codeGen/1.5/om/xsAttribute.php @@ -0,0 +1,27 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +class xsAttribute extends _elementSet +{ + function xsAttribute() + { + $this->_addAttribute( 'name', array( 'type' => 'xs:string' ) ); + $this->_addAttribute( 'type', array( 'type' => 'xs:string' ) ); + $this->_addAttribute( 'use', array( 'type' => 'xs:string' ) ); + $this->_addAttribute( 'default', array( 'type' => 'xs:string' ) ); + $this->_addAttribute( 'ref', array( 'type' => 'xs:string' ) ); + + $this->_addElement( 'xsAnnotation', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + + $this->type[] = 'xsAttribute'; + parent::_typedData(); + } +} + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.5/om/xsChoice.php b/1.4.0/dom/codeGen/1.5/om/xsChoice.php new file mode 100644 index 0000000..9d31c5d --- /dev/null +++ b/1.4.0/dom/codeGen/1.5/om/xsChoice.php @@ -0,0 +1,31 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +class xsChoice extends _elementSet +{ + function xsChoice() + { + $this->_addElement( 'xsElement', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsAttribute', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsChoice', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsSequence', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsGroup', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsAnnotation', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + + $this->type[] = "xsChoice"; + parent::_elementSet(); + } + + function addChoiceElement( & $e ) + { + $this->addElement( $e ); + } +} + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.5/om/xsComplexContent.php b/1.4.0/dom/codeGen/1.5/om/xsComplexContent.php new file mode 100644 index 0000000..2dd1d74 --- /dev/null +++ b/1.4.0/dom/codeGen/1.5/om/xsComplexContent.php @@ -0,0 +1,24 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +class xsComplexContent extends _elementSet +{ + function xsComplexContent() + { + $this->_addElement( 'xsRestriction', array( 'minOccurs' => '1', 'maxOccurs' => '1' ) ); + $this->_addElement( 'xsExtension', array( 'minOccurs' => '1', 'maxOccurs' => '1' ) ); + +// $this->_addAttribute( 'name', array( 'type' => 'xs:string' ) ); + + $this->type[] = 'xsComplexContent'; + parent::_elementSet(); + } +} + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.5/om/xsComplexType.php b/1.4.0/dom/codeGen/1.5/om/xsComplexType.php new file mode 100644 index 0000000..c134c1c --- /dev/null +++ b/1.4.0/dom/codeGen/1.5/om/xsComplexType.php @@ -0,0 +1,228 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +class xsComplexType extends _elementSet +{ + function xsComplexType() + { + $this->_addElement( 'xsAnnotation', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsChoice', array( 'minOccurs' => '1', 'maxOccurs' => '1' ) ); + $this->_addElement( 'xsAttribute', array( 'minOccurs' => '1', 'maxOccurs' => '1' ) ); + $this->_addElement( 'xsSequence', array( 'minOccurs' => '1', 'maxOccurs' => '1' ) ); + $this->_addElement( 'xsAll', array( 'minOccurs' => '1', 'maxOccurs' => '1' ) ); + $this->_addElement( 'xsGroup', array( 'minOccurs' => '1', 'maxOccurs' => '1' ) ); + $this->_addElement( 'xsSimpleContent', array( 'minOccurs' => '1', 'maxOccurs' => '1' ) ); + $this->_addElement( 'xsComplexContent', array( 'minOccurs' => '1', 'maxOccurs' => '1' ) ); + + $this->_addAttribute( 'name', array( 'type' => 'xs:string' ) ); + $this->_addAttribute( 'mixed', array( 'type' => 'xs:string', 'default' => 'false' ) ); + + $this->type[] = 'xsComplexType'; + parent::_elementSet(); + } + + function & generate( $element_context, & $global_elements ) + { + $element_context[] = $this->getAttribute( "name" ); + print implode( ",", $element_context ) . "\n"; + + // Get new factory + $generator = new ElementMeta( $global_elements ); + $generator->setIsAComplexType( true ); + + // Load the class name and a context pre-fix (in case we're inside another element) + $generator->setName( $this->getAttribute( 'name' ) ); + $generator->setContext( $element_context ); + + // Extract any documentation for this node + $a = $this->getElementsByType( 'xsAnnotation' ); + if ( count( $a ) > 0 ) + { + $d = $a[0]->getElementsByType( 'xsDocumentation' ); + if ( count( $d ) > 0 ) + { + $generator->setDocumentation( $d[0]->get() ); + } + } + if ( $this->getAttribute( 'mixed' ) == 'true' ) + { + $generator->setMixed( true ); + } + + $content = $this; // Should only be one + $this->generateComplexType( $content, $generator, $element_context ); + + if ( count( $generator->bag['elements'] ) == 0 ) { + $generator->setIsEmptyContent( true ); + } + + $meta = & $generator->getMeta(); + + if ( count( $element_context ) == 1 ) + { + $global_elements[ $element_context[0] ] = & $meta; + } + + return $meta; + } + + // Flatten choice/all/sequence groups into a single list of contained elements + function flatten( & $element, & $generator, & $context, $maxOccurs ) + { + //print "in flatten "; + $e_list = $element->getElements(); + for( $i=0; $i<count( $e_list ); $i++ ) + { + switch( $e_list[$i]->getType() ) + { + case 'xsChoice': + $generator->setHasChoice( true ); + $generator->addContentModel( 1, $e_list[$i]->getAttribute( 'minOccurs' ), $e_list[$i]->getAttribute( 'maxOccurs' ) ); + // Propagate the maxOccurs down through choice hierarchy (while flattening) + $local_max = $e_list[$i]->getAttribute( 'maxOccurs' ); + if ( $maxOccurs == 'unbounded' || (is_int( $local_max ) && ($maxOccurs > $local_max)) ) + { + $this->flatten( $e_list[$i], $generator, $context, $maxOccurs ); + } else + { + $this->flatten( $e_list[$i], $generator, $context, $local_max ); + } + break; + case 'xsSequence': + $generator->addContentModel( 0, $e_list[$i]->getAttribute( 'minOccurs' ), $e_list[$i]->getAttribute( 'maxOccurs' ) ); + // Propagate the maxOccurs down through choice hierarchy (while flattening) + $local_max = $e_list[$i]->getAttribute( 'maxOccurs' ); + if ( $maxOccurs == 'unbounded' || (is_int( $local_max ) && ($maxOccurs > $local_max)) ) + { + $this->flatten( $e_list[$i], $generator, $context, $maxOccurs ); + } else + { + $this->flatten( $e_list[$i], $generator, $context, $local_max ); + } + break; + case 'xsAll': + $generator->addContentModel( 3, $e_list[$i]->getAttribute( 'minOccurs' ), $e_list[$i]->getAttribute( 'maxOccurs' ) ); + // Propagate the maxOccurs down through choice hierarchy (while flattening) + $local_max = $e_list[$i]->getAttribute( 'maxOccurs' ); + if ( $maxOccurs == 'unbounded' || (is_int( $local_max ) && ($maxOccurs > $local_max)) ) + { + $this->flatten( $e_list[$i], $generator, $context, $maxOccurs ); + } else + { + $this->flatten( $e_list[$i], $generator, $context, $local_max ); + } + break; + case 'xsGroup': + $generator->addContentModel( 2, $e_list[$i]->getAttribute( 'minOccurs' ), $e_list[$i]->getAttribute( 'maxOccurs' ) ); + $generator->addGroup( $e_list[$i] ); + case 'xsElement': + $nm = $e_list[$i]->getAttribute( 'name' ); + if ( $nm == '' ) { $nm = $e_list[$i]->getAttribute( 'ref' ); } + $generator->addContentModel( $nm, $e_list[$i]->getAttribute( 'minOccurs' ), $e_list[$i]->getAttribute( 'maxOccurs' ) ); + //print "found element!\n"; + // If a containing element/group has a maxOccurs > 1, then inherit it (will flag as array in code gen) + if ( $maxOccurs == 'unbounded' || $maxOccurs > 1 ) + { + $e_list[$i]->setAttribute( 'maxOccurs', $maxOccurs ); + } + $generator->addElement( $e_list[$i], $context ); + break; + case 'xsAttribute': + //print "found attribute!\n"; + $generator->addAttribute( $e_list[$i] ); + break; + case 'xsAny': + print "found an any\n"; + $generator->addContentModel( 4, $e_list[$i]->getAttribute( 'minOccurs' ), $e_list[$i]->getAttribute( 'maxOccurs' ) ); + $generator->bag['has_any'] = true; + break; + default: + break; + } + } + $generator->addContentModel( 5, 0, 0 ); //END content model - There will be one extra on every element + } + + //function that reads complex types. will recurse complex type derived heirarchies. + function generateComplexType( $content, & $generator, & $context ) { + //print "in generatecomplextype\n"; + if ( count( $content->getElementsByType( 'xsSimpleContent' ) ) > 0 ) { + //print "found simpleContent!\n"; + $temp = $content->getElementsByType( 'xsSimpleContent' ); + $content = $temp[0]; // Should only be one - now we now find out element's parent class + $temp = & $content->getElements(); + $content = $temp[0]; // Should either be an xsExtension or xsRestriction + $type = $content->getAttribute( 'base' ); + //print "setting extends to ". $type ."\n"; + $generator->setContentType( $type ); + if ($content instanceof xsRestriction) { + $generator->bag['baseTypeViaRestriction'] = $type; + $generator->bag['base_type'] = $type; + } + $temp = & $content->getElementsByType( 'xsAttribute' ); + for( $i=0; $i<count( $temp ); $i++ ) { + $generator->addAttribute( $temp[$i] ); + } + } else if ( count( $content->getElementsByType( 'xsComplexContent' ) ) > 0 ) { + //print "found complexContent!\n"; + //ComplexContent specified means type is derived + $temp = $content->getElementsByType( 'xsComplexContent' ); + $content = $temp[0]; // Should only be one - now we now find out element's parent class + $temp = & $content->getElements(); + $content = $temp[0]; // Should either be an xsExtension or xsRestriction + if ( $content->getType() == 'xsExtension' ) { + $generator->bag['isExtension'] = true; + } + if ( $content->getType() == 'xsRestriction' ) { + $generator->bag['isRestriction'] = true; + } + $type = $content->getAttribute( 'base' ); + if ($content instanceof xsRestriction) + $generator->bag['baseTypeViaRestriction'] = $type; + //print "setting extends to ". $type ."\n"; + $generator->bag['base_type'] = $type; + //Generate the complex type this is derived from + //*************CHANGE NEEDED HERE 8-25 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + for ( $i = 0; $i < count( $GLOBALS['_globals']['complex_types'] ); $i++ ) { + if ( $type == $GLOBALS['_globals']['complex_types'][$i]->getAttribute('name') ) { + $generator->setComplexType( true ); + $generator->bag['ref_elements'][] = $type; + //$this->generateComplexType( $GLOBALS['_globals']['complex_types'][$i], $generator, $context ); + break; + } + } + + // Parse element context + $this->flatten( $content, $generator, $element_context, $content->getAttribute( 'maxOccurs' ) ); + + } else { + //print "found nothing so doing complex content flatten\n"; + // The alternative to xsSimpleContent is xsComplexContent - if it is not specified, it is implied + // Parse element context + $this->flatten( $content, $generator, $element_context, $content->getAttribute( 'maxOccurs' ) ); + if ( count( $generator->bag['elements'] ) == 0 ) { + $generator->setIsEmptyContent( true ); + } + } + } + + function & generateType() { + $vars = array(); + $e = $this->getElements(); + $generator = new TypeMeta(); + + $generator->setType( $this->getAttribute( 'name' ) ); + $generator->setIsComplex( true ); + + $meta = & $generator->getMeta(); + return $meta; + } +} + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.5/om/xsDocumentation.php b/1.4.0/dom/codeGen/1.5/om/xsDocumentation.php new file mode 100644 index 0000000..a89ca8e --- /dev/null +++ b/1.4.0/dom/codeGen/1.5/om/xsDocumentation.php @@ -0,0 +1,19 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +class xsDocumentation extends _typedData +{ + function xsDocumentation() + { + $this->type[] = "xsDocumentation"; + parent::_typedData(); + } +} + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.5/om/xsElement.php b/1.4.0/dom/codeGen/1.5/om/xsElement.php new file mode 100644 index 0000000..1aa0c8e --- /dev/null +++ b/1.4.0/dom/codeGen/1.5/om/xsElement.php @@ -0,0 +1,368 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +require_once( 'src/ElementMeta.php' ); +require_once( 'src/TypeMeta.php' ); + +class xsElement extends _elementSet +{ + function xsElement() + { + $this->_addElement( 'xsAnnotation', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsComplexType', array( 'minOccurs' => '0', 'maxOccurs' => '1' ) ); + $this->_addElement( 'xsSimpleType', array( 'minOccurs' => '0', 'maxOccurs' => '1' ) ); + + $this->_addAttribute( 'ref', array( 'type' => 'xs:string' ) ); + $this->_addAttribute( 'name', array( 'type' => 'xs:string' ) ); + $this->_addAttribute( 'type', array( 'type' => 'xs:string' ) ); + $this->_addAttribute( 'abstract', array( 'type' => 'xs:bool' ) ); + $this->_addAttribute( 'substitutionGroup', array( 'type' => 'xs:string' ) ); +// $this->_addAttribute( 'maxOccurs', array( 'type' => 'xs:integer' ) ); +// $this->_addAttribute( 'minOccurs', array( 'type' => 'xs:integer' ) ); + + $this->type[] = 'xsElement'; + parent::_elementSet(); + } + + function & generate( $element_context, & $global_elements ) + { + $element_context[] = $this->getAttribute( "name" ); + print implode( ",", $element_context ) . "\n"; + + // Get new factory + $generator = new ElementMeta( $global_elements ); + + // Load the class name and a context pre-fix (in case we're inside another element) + $generator->setName( $this->getAttribute( 'name' ) ); + $generator->setContext( $element_context ); + $subGroup = $this->getAttribute( 'substitutionGroup' ); + if ( $subGroup != '' ) { + //print "found a subGroup ". $subGroup ."!\n"; + $generator->setSubstitutionGroup( $subGroup ); + $generator->bag['ref_elements'][] = $subGroup; + } + $abstract = $this->getAttribute( 'abstract' ); + if ( $abstract != '' ) { + $generator->setAbstract( $abstract ); + } + + // Extract any documentation for this node + $a = $this->getElementsByType( 'xsAnnotation' ); + if ( count( $a ) > 0 ) + { + $d = $a[0]->getElementsByType( 'xsDocumentation' ); + if ( count( $d ) > 0 ) + { + $generator->setDocumentation( $d[0]->get() ); + } + $ap = $a[0]->getElementsByType( 'xsAppinfo' ); + if ( count( $ap ) > 0 ) + { + $generator->setAppInfo( $ap[0]->get() ); + } + } + + //******************************************************************************************/ + //$generator->setContentType( $this->getAttribute( 'type' ) ); + $type = $this->getAttribute( 'type' ); + $generator->bag['base_type'] = $type; + //check if this type equals a complex type + //print "element ". $this->getAttribute( 'name' ) ." is of type ". $type ."!\n"; + if ( $type != "" ) { + //print "complex types: " . count($GLOBALS['_globals']['complex_types']) . "\n"; + for ( $i = 0; $i < count( $GLOBALS['_globals']['complex_types'] ); $i++ ) { + if ( !strcmp($type, $GLOBALS['_globals']['complex_types'][$i]->getAttribute('name') ) ) { + //print "found a match for ". $type ."\n"; + $generator->setComplexType( true ); + $generator->bag['ref_elements'][] = $type; + break; + } + } + if ( !$generator->bag['complex_type'] ) { + //wasn't a complex type that means it needs a content type + $generator->setContentType( $type ); + } + } + //*******************************************************************************************/ + + // Inspect the semantic structure of this node and extract the elements/attributes + $temp = $this->getElementsByType( 'xsComplexType' ); + + if ( count( $temp ) > 0 ) + { + if ( $temp[0]->getAttribute( 'mixed' ) == 'true' ) + { + $generator->setMixed( true ); + $generator->setContentType( 'ListOfInts' ); + } + + $content = $temp[0]; // Should only be one + $this->generateComplexType( $content, $generator, $element_context ); + if ( count( $generator->bag['elements'] ) == 0 ) { + $generator->setIsEmptyContent( true ); + } + } + else if ( count( $this->getElementsByType( 'xsSimpleType' ) ) > 0 ) { + //inline simple type definition. right now handle as string but needs to be fixed + $generator->bag['simple_type'] = new TypeMeta(); + $temp = $this->getElementsByType( 'xsSimpleType' ); + $this->generateSimpleType( $temp[0], $generator->bag['simple_type'] ); + if ( count( $generator->bag['simple_type']->bag['enum'] ) >0 ) { + $generator->setContentType( $this->getAttribute( 'name' ) ."_type" ); + } + else { + $generator->setContentType( $generator->bag['simple_type']->bag['base'] ); + } + } + + $meta = & $generator->getMeta(); + + if ( count( $element_context ) == 1 ) + { + $global_elements[ $element_context[0] ] = & $meta; + } + + return $meta; + } + + // Flatten choice/all/sequence groups into a single list of contained elements + function flatten( & $element, & $generator, & $context, $maxOccurs ) + { + //print "in flatten "; + $e_list = $element->getElements(); + for( $i=0; $i<count( $e_list ); $i++ ) + { + switch( $e_list[$i]->getType() ) + { + case 'xsChoice': + $generator->setHasChoice( true ); + $generator->addContentModel( 1, $e_list[$i]->getAttribute( 'minOccurs' ), $e_list[$i]->getAttribute( 'maxOccurs' ) ); + // Propagate the maxOccurs down through choice hierarchy (while flattening) + $local_max = $e_list[$i]->getAttribute( 'maxOccurs' ); + if ( $maxOccurs == 'unbounded' || (is_int( $local_max ) && ($maxOccurs > $local_max)) ) + { + $this->flatten( $e_list[$i], $generator, $context, $maxOccurs ); + } else + { + $this->flatten( $e_list[$i], $generator, $context, $local_max ); + } + break; + case 'xsSequence': + $generator->addContentModel( 0, $e_list[$i]->getAttribute( 'minOccurs' ), $e_list[$i]->getAttribute( 'maxOccurs' ) ); + // Propagate the maxOccurs down through choice hierarchy (while flattening) + $local_max = $e_list[$i]->getAttribute( 'maxOccurs' ); + if ( $maxOccurs == 'unbounded' || (is_int( $local_max ) && ($maxOccurs > $local_max)) ) + { + $this->flatten( $e_list[$i], $generator, $context, $maxOccurs ); + } else + { + $this->flatten( $e_list[$i], $generator, $context, $local_max ); + } + break; + case 'xsAll': + $generator->addContentModel( 3, $e_list[$i]->getAttribute( 'minOccurs' ), $e_list[$i]->getAttribute( 'maxOccurs' ) ); + // Propagate the maxOccurs down through choice hierarchy (while flattening) + $local_max = $e_list[$i]->getAttribute( 'maxOccurs' ); + if ( $maxOccurs == 'unbounded' || (is_int( $local_max ) && ($maxOccurs > $local_max)) ) + { + $this->flatten( $e_list[$i], $generator, $context, $maxOccurs ); + } else + { + $this->flatten( $e_list[$i], $generator, $context, $local_max ); + } + break; + case 'xsGroup': + $generator->addContentModel( 2, $e_list[$i]->getAttribute( 'minOccurs' ), $e_list[$i]->getAttribute( 'maxOccurs' ) ); + $generator->addGroup( $e_list[$i] ); + case 'xsElement': + $nm = $e_list[$i]->getAttribute( 'name' ); + if ( $nm == '' ) { $nm = $e_list[$i]->getAttribute( 'ref' ); } + $generator->addContentModel( $nm, $e_list[$i]->getAttribute( 'minOccurs' ), $e_list[$i]->getAttribute( 'maxOccurs' ) ); + //print "found element!\n"; + // If a containing element/group has a maxOccurs > 1, then inherit it (will flag as array in code gen) + if ( $maxOccurs == 'unbounded' || $maxOccurs > 1 ) + { + $e_list[$i]->setAttribute( 'maxOccurs', $maxOccurs ); + } + $generator->addElement( $e_list[$i], $context ); + break; + case 'xsAttribute': + //print "found attribute!\n"; + $generator->addAttribute( $e_list[$i] ); + break; + case 'xsAny': + print "found an any\n"; + $generator->addContentModel( 4, $e_list[$i]->getAttribute( 'minOccurs' ), $e_list[$i]->getAttribute( 'maxOccurs' ) ); + $generator->bag['has_any'] = true; + break; + default: + break; + } + } + $generator->addContentModel( 5, 0, 0 ); //END content model - There will be one extra on every element + } + + //function that reads complex types. will recurse complex type derived heirarchies. + function generateComplexType( $content, & $generator, & $context ) { + //print "in generatecomplextype\n"; + if ( count( $content->getElementsByType( 'xsSimpleContent' ) ) > 0 ) { + //print "found simpleContent!\n"; + $temp = $content->getElementsByType( 'xsSimpleContent' ); + $content = $temp[0]; // Should only be one - now we now find out element's parent class + $temp = & $content->getElements(); + $content = $temp[0]; // Should either be an xsExtension or xsRestriction + $type = $content->getAttribute( 'base' ); + //print "setting extends to ". $type ."\n"; + $generator->setContentType( $type ); + $temp = & $content->getElementsByType( 'xsAttribute' ); + for( $i=0; $i<count( $temp ); $i++ ) { + $generator->addAttribute( $temp[$i] ); + } + } else if ( count( $content->getElementsByType( 'xsComplexContent' ) ) > 0 ) { + //print "found complexContent!\n"; + //ComplexContent specified means type is derived + $temp = $content->getElementsByType( 'xsComplexContent' ); + $content = $temp[0]; // Should only be one - now we now find out element's parent class + $temp = & $content->getElements(); + $content = $temp[0]; // Should either be an xsExtension or xsRestriction + if ( $content->getType() == 'xsExtension' ) { + $generator->bag['isExtension'] = true; + } + if ( $content->getType() == 'xsRestriction' ) { + $generator->bag['isRestriction'] = true; + } + $type = $content->getAttribute( 'base' ); + //print "setting extends to ". $type ."\n"; + $generator->bag['base_type'] = $type; + //Generate the complex type this is derived from + for ( $i = 0; $i < count( $GLOBALS['_globals']['complex_types'] ); $i++ ) { + if ( $type == $GLOBALS['_globals']['complex_types'][$i]->getAttribute('name') ) { + $generator->setComplexType( true ); + $generator->bag['ref_elements'][] = $type; + //$this->generateComplexType( $GLOBALS['_globals']['complex_types'][$i], $generator, $context ); + break; + } + } + + // Parse element context + $this->flatten( $content, $generator, $element_context, $content->getAttribute( 'maxOccurs' ) ); + + } else { + //print "found nothing so doing complex content flatten\n"; + // The alternative to xsSimpleContent is xsComplexContent - if it is not specified, it is implied + // Parse element context + $this->flatten( $content, $generator, $element_context, $content->getAttribute( 'maxOccurs' ) ); + + } + } + + //function that generates the inline simpleType + function generateSimpleType( $content, & $generator ) { + + $e = $content->getElements(); + $generator->setType( $this->getAttribute( 'name' ) ); + //print $this->getAttribute( 'name' ) ." has a simpletype\n"; + $a = $content->getElementsByType( 'xsAnnotation' ); + if ( count( $a ) > 0 ) { + //print "found annotation for ". $this->getAttribute( 'name' ) ."!\n"; + $d = $a[0]->getElementsByType( 'xsDocumentation' ); + if ( count( $d ) > 0 ) + { + //print "found documentation for ". $this->getAttribute( 'name' ) ."!\n"; + $generator->setDocumentation( $d[0]->get() ); + } + $ap = $a[0]->getElementsByType( 'xsAppinfo' ); + if ( count( $ap ) > 0 ) + { + $generator->setAppInfo( $ap[0]->get() ); + } + } + + $idx = 0; + if ( $e[$idx]->getType() == 'xsAnnotation' ) { + $idx = 1; + } + if ( $e[$idx]->getType() == 'xsRestriction' || $e[$idx]->getType() == 'xsExtension' ) + { + $generator->setIsExtension( $e[$idx]->getType() == 'xsExtension' ); + + // Set base class + $generator->setBase( $e[$idx]->getAttribute( 'base' ) ); + + // Look for enums + $enums = $e[$idx]->getElementsByType( 'xsEnumeration' ); + for( $i=0; $i<count( $enums ); $i++ ) + { + $generator->addEnum( $enums[$i]->getAttribute( 'value' ) ); + //print $enums[$i]->getAttribute( 'value' ); + $an = $enums[$i]->getElementsByType('xsAnnotation'); + if ( count( $an ) > 0 ) { + $doc = $an[0]->getElementsByType( 'xsDocumentation' ); + if ( count( $doc ) > 0 ) { + $generator->addEnumDoc( $i, $doc[0]->get() ); + } + $ap = $an[0]->getElementsByType( 'xsAppinfo' ); + if ( count( $ap ) > 0 ) + { + $generator->addEnumAppInfo( $i, $ap[0]->get() ); + } + } + } + + // Look for max/mins + $array_limits = array(); + $min = $e[$idx]->getElementsByType( 'xsMinLength' ); + $max = $e[$idx]->getElementsByType( 'xsMaxLength' ); + $minIn = $e[$idx]->getElementsByType( 'xsMinInclusive' ); + $maxIn = $e[$idx]->getElementsByType( 'xsMaxInclusive' ); + $minEx = $e[$idx]->getElementsByType( 'xsMinExclusive' ); + $maxEx = $e[$idx]->getElementsByType( 'xsMaxExclusive' ); + + if ( count( $min ) > 0 ) + { + $generator->setRestriction( 'minLength', $min[0]->getAttribute( 'value' ) ); + } + + if ( count( $max ) > 0 ) + { + $generator->setRestriction( 'maxLength', $max[0]->getAttribute( 'value' ) ); + } + + if ( count( $minIn ) > 0 ) + { + $generator->setRestriction( 'minInclusive', $minIn[0]->getAttribute( 'value' ) ); + } + + if ( count( $maxIn ) > 0 ) + { + $generator->setRestriction( 'maxInclusive', $maxIn[0]->getAttribute( 'value' ) ); + } + + if ( count( $minEx ) > 0 ) + { + $generator->setRestriction( 'minExclusive', $minEx[0]->getAttribute( 'value' ) ); + } + + if ( count( $maxEx ) > 0 ) + { + $generator->setRestriction( 'maxExclusive', $maxEx[0]->getAttribute( 'value' ) ); + } + } else if ( $e[$idx]->getType() == 'xsList' ) + { + //$extends = "xsList"; + $itemType = $e[$idx]->getAttribute( 'itemType' ); + $generator->setListType( $itemType ); + $generator->bag['isArray'] = true; + } else + { + $this->log( "WARN: unexpected element in xsSimpleType code generation" ); + } + } +} +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.5/om/xsEnumeration.php b/1.4.0/dom/codeGen/1.5/om/xsEnumeration.php new file mode 100644 index 0000000..5b5a2c7 --- /dev/null +++ b/1.4.0/dom/codeGen/1.5/om/xsEnumeration.php @@ -0,0 +1,23 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +class xsEnumeration extends _elementSet +{ + function xsEnumeration() + { + $this->_addAttribute( 'value', array( 'type' => 'xs:integer' ) ); + + $this->_addElement( 'xsAnnotation', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + + $this->type[] = 'xsEnumeration'; + parent::_typedData(); + } +} + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.5/om/xsExtension.php b/1.4.0/dom/codeGen/1.5/om/xsExtension.php new file mode 100644 index 0000000..e0ff68a --- /dev/null +++ b/1.4.0/dom/codeGen/1.5/om/xsExtension.php @@ -0,0 +1,24 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +class xsExtension extends _elementSet +{ + function xsExtension() + { + $this->_addElement( 'xsAttribute', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsSequence', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + + $this->_addAttribute( 'base', array( 'type' => 'xs:string' ) ); + + $this->type[] = 'xsExtension'; + parent::_elementSet(); + } +} + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.5/om/xsGroup.php b/1.4.0/dom/codeGen/1.5/om/xsGroup.php new file mode 100644 index 0000000..4356087 --- /dev/null +++ b/1.4.0/dom/codeGen/1.5/om/xsGroup.php @@ -0,0 +1,152 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +class xsGroup extends _elementSet +{ + function xsGroup() + { + $this->_addElement( 'xsAnnotation', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsElement', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsAttribute', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsChoice', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsSequence', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsGroup', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + + $this->_addAttribute( 'ref', array( 'type' => 'xs:string' ) ); + $this->_addAttribute( 'name', array( 'type' => 'xs:string' ) ); + + $this->type[] = "xsGroup"; + parent::_elementSet(); + } + + function addChoiceElement( & $e ) + { + $this->addElement( $e ); + } + + function & generate( $element_context, & $global_elements ) + { + $element_context[] = $this->getAttribute( "name" ); + print implode( ",", $element_context ) . "\n"; + + // Get new factory + $generator = new ElementMeta( $global_elements ); + $generator->setIsAGroup( true ); + + // Load the class name and a context pre-fix (in case we're inside another element) + $generator->setName( $this->getAttribute( 'name' ) ); + $generator->setContext( $element_context ); + + // Extract any documentation for this node + $a = $this->getElementsByType( 'xsAnnotation' ); + if ( count( $a ) > 0 ) + { + $d = $a[0]->getElementsByType( 'xsDocumentation' ); + if ( count( $d ) > 0 ) + { + $generator->setDocumentation( $d[0]->get() ); + } + } + + // Inspect the semantic structure of this node and extract the elements/attributes + $this->flatten( $this, $generator, $element_context, $this->getAttribute( 'maxOccurs' ) ); + + if ( count( $generator->bag['elements'] ) == 0 ) { + $generator->setIsEmptyContent( true ); + } + + $meta = & $generator->getMeta(); + + if ( count( $element_context ) == 1 ) + { + $global_elements[ $element_context[0] ] = & $meta; + } + + return $meta; + } + + // Flatten choice/all/sequence groups into a single list of contained elements + function flatten( & $element, & $generator, & $context, $maxOccurs ) + { + //print "in flatten "; + $e_list = $element->getElements(); + for( $i=0; $i<count( $e_list ); $i++ ) + { + switch( $e_list[$i]->getType() ) + { + case 'xsChoice': + $generator->setHasChoice( true ); + $generator->addContentModel( 1, $e_list[$i]->getAttribute( 'minOccurs' ), $e_list[$i]->getAttribute( 'maxOccurs' ) ); + // Propagate the maxOccurs down through choice hierarchy (while flattening) + $local_max = $e_list[$i]->getAttribute( 'maxOccurs' ); + if ( $maxOccurs == 'unbounded' || (is_int( $local_max ) && ($maxOccurs > $local_max)) ) + { + $this->flatten( $e_list[$i], $generator, $context, $maxOccurs ); + } else + { + $this->flatten( $e_list[$i], $generator, $context, $local_max ); + } + break; + case 'xsSequence': + $generator->addContentModel( 0, $e_list[$i]->getAttribute( 'minOccurs' ), $e_list[$i]->getAttribute( 'maxOccurs' ) ); + // Propagate the maxOccurs down through choice hierarchy (while flattening) + $local_max = $e_list[$i]->getAttribute( 'maxOccurs' ); + if ( $maxOccurs == 'unbounded' || (is_int( $local_max ) && ($maxOccurs > $local_max)) ) + { + $this->flatten( $e_list[$i], $generator, $context, $maxOccurs ); + } else + { + $this->flatten( $e_list[$i], $generator, $context, $local_max ); + } + break; + case 'xsAll': + $generator->addContentModel( 3, $e_list[$i]->getAttribute( 'minOccurs' ), $e_list[$i]->getAttribute( 'maxOccurs' ) ); + // Propagate the maxOccurs down through choice hierarchy (while flattening) + $local_max = $e_list[$i]->getAttribute( 'maxOccurs' ); + if ( $maxOccurs == 'unbounded' || (is_int( $local_max ) && ($maxOccurs > $local_max)) ) + { + $this->flatten( $e_list[$i], $generator, $context, $maxOccurs ); + } else + { + $this->flatten( $e_list[$i], $generator, $context, $local_max ); + } + break; + case 'xsGroup': + $generator->addContentModel( 2, $e_list[$i]->getAttribute( 'minOccurs' ), $e_list[$i]->getAttribute( 'maxOccurs' ) ); + $generator->addGroup( $e_list[$i] ); + case 'xsElement': + $nm = $e_list[$i]->getAttribute( 'name' ); + if ( $nm == '' ) { $nm = $e_list[$i]->getAttribute( 'ref' ); } + $generator->addContentModel( $nm, $e_list[$i]->getAttribute( 'minOccurs' ), $e_list[$i]->getAttribute( 'maxOccurs' ) ); + //print "found element!\n"; + // If a containing element/group has a maxOccurs > 1, then inherit it (will flag as array in code gen) + if ( $maxOccurs == 'unbounded' || $maxOccurs > 1 ) + { + $e_list[$i]->setAttribute( 'maxOccurs', $maxOccurs ); + } + $generator->addElement( $e_list[$i], $context ); + break; + case 'xsAttribute': + //print "found attribute!\n"; + $generator->addAttribute( $e_list[$i] ); + break; + case 'xsAny': + print "found an any\n"; + $generator->addContentModel( 4, $e_list[$i]->getAttribute( 'minOccurs' ), $e_list[$i]->getAttribute( 'maxOccurs' ) ); + $generator->bag['has_any'] = true; + break; + default: + break; + } + } + $generator->addContentModel( 5, 0, 0 ); //END content model - There will be one extra on every element + } +} + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.5/om/xsImport.php b/1.4.0/dom/codeGen/1.5/om/xsImport.php new file mode 100644 index 0000000..1f5e6d0 --- /dev/null +++ b/1.4.0/dom/codeGen/1.5/om/xsImport.php @@ -0,0 +1,22 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +class xsImport extends _typedData +{ + function xsImport() + { + $this->_addAttribute( 'namespace', array( 'type' => 'xs:string' ) ); + $this->_addAttribute( 'schemaLocation', array( 'type' => 'xs:string' ) ); + + $this->type[] = 'xsImport'; + parent::_typedData(); + } +} + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.5/om/xsList.php b/1.4.0/dom/codeGen/1.5/om/xsList.php new file mode 100644 index 0000000..b1ce038 --- /dev/null +++ b/1.4.0/dom/codeGen/1.5/om/xsList.php @@ -0,0 +1,49 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +class xsList extends _typedData +{ + var $minLength; + var $maxLength; + + function xsList() + { + global $MAX_ARRAY_LENGTH; + + $this->minLength = 0; + $this->maxLength = $MAX_ARRAY_LENGTH; + + $this->_addAttribute( 'itemType', array( 'type' => 'xs:string' ) ); + $this->setAttribute( 'itemType', 'TypedData' ); + + $this->type[] = 'xsList'; + parent::_typedData(); + } + + // To save the heavyweight object-per-data-point approach, allow a list type + // to parse the buffer into a single array + function set( & $buffer ) + { + eval( '$type = new ' . $this->getAttribute( 'itemType' ) . '();' ); + $this->data = & $type->parse( $buffer ); + +/* for( $i=0; trim( $buffer ) != "" && $i<$this->maxLength; $i++ ) + { + eval( '$this->data[ $i ] = new ' . $this->getAttribute( 'itemType' ) . '();' ); + $this->data[ $i ]->set( $buffer ); + }*/ + } + + function getCount() + { + return count( $this->data ); + } +} + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.5/om/xsMaxExclusive.php b/1.4.0/dom/codeGen/1.5/om/xsMaxExclusive.php new file mode 100644 index 0000000..8abec02 --- /dev/null +++ b/1.4.0/dom/codeGen/1.5/om/xsMaxExclusive.php @@ -0,0 +1,21 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +class xsMaxExclusive extends _typedData +{ + function xsMaxExclusive() + { + $this->_addAttribute( 'value', array( 'type' => 'xs:float' ) ); + + $this->type[] = 'xsMaxExclusive'; + parent::_typedData(); + } +} + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.5/om/xsMaxInclusive.php b/1.4.0/dom/codeGen/1.5/om/xsMaxInclusive.php new file mode 100644 index 0000000..8707dc9 --- /dev/null +++ b/1.4.0/dom/codeGen/1.5/om/xsMaxInclusive.php @@ -0,0 +1,21 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +class xsMaxInclusive extends _typedData +{ + function xsMaxInclusive() + { + $this->_addAttribute( 'value', array( 'type' => 'xs:float' ) ); + + $this->type[] = 'xsMaxInclusive'; + parent::_typedData(); + } +} + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.5/om/xsMaxLength.php b/1.4.0/dom/codeGen/1.5/om/xsMaxLength.php new file mode 100644 index 0000000..6394e9b --- /dev/null +++ b/1.4.0/dom/codeGen/1.5/om/xsMaxLength.php @@ -0,0 +1,21 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +class xsMaxLength extends _typedData +{ + function xsMaxLength() + { + $this->_addAttribute( 'value', array( 'type' => 'xs:integer' ) ); + + $this->type[] = 'xsMaxLength'; + parent::_typedData(); + } +} + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.5/om/xsMinExclusive.php b/1.4.0/dom/codeGen/1.5/om/xsMinExclusive.php new file mode 100644 index 0000000..4f02bd3 --- /dev/null +++ b/1.4.0/dom/codeGen/1.5/om/xsMinExclusive.php @@ -0,0 +1,21 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +class xsMinExclusive extends _typedData +{ + function xsMinExclusive() + { + $this->_addAttribute( 'value', array( 'type' => 'xs:float' ) ); + + $this->type[] = 'xsMinExclusive'; + parent::_typedData(); + } +} + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.5/om/xsMinInclusive.php b/1.4.0/dom/codeGen/1.5/om/xsMinInclusive.php new file mode 100644 index 0000000..34ee962 --- /dev/null +++ b/1.4.0/dom/codeGen/1.5/om/xsMinInclusive.php @@ -0,0 +1,21 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +class xsMinInclusive extends _typedData +{ + function xsMinInclusive() + { + $this->_addAttribute( 'value', array( 'type' => 'xs:float' ) ); + + $this->type[] = 'xsMinInclusive'; + parent::_typedData(); + } +} + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.5/om/xsMinLength.php b/1.4.0/dom/codeGen/1.5/om/xsMinLength.php new file mode 100644 index 0000000..809243f --- /dev/null +++ b/1.4.0/dom/codeGen/1.5/om/xsMinLength.php @@ -0,0 +1,21 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +class xsMinLength extends _typedData +{ + function xsMinLength() + { + $this->_addAttribute( 'value', array( 'type' => 'xs:integer' ) ); + + $this->type[] = 'xsMinLength'; + parent::_typedData(); + } +} + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.5/om/xsPattern.php b/1.4.0/dom/codeGen/1.5/om/xsPattern.php new file mode 100644 index 0000000..f679594 --- /dev/null +++ b/1.4.0/dom/codeGen/1.5/om/xsPattern.php @@ -0,0 +1,23 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +class xsPattern extends _elementSet +{ + function xsPattern() + { + $this->_addAttribute( 'value', array( 'type' => 'xs:string' ) ); + + $this->_addElement( 'xsAnnotation', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + + $this->type[] = 'xsPattern'; + parent::_typedData(); + } +} + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.5/om/xsRestriction.php b/1.4.0/dom/codeGen/1.5/om/xsRestriction.php new file mode 100644 index 0000000..61a96b0 --- /dev/null +++ b/1.4.0/dom/codeGen/1.5/om/xsRestriction.php @@ -0,0 +1,32 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +class xsRestriction extends _elementSet +{ + function xsRestriction() + { + $this->_addElement( 'xsAttribute', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsMinLength', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsMaxLength', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsMinInclusive', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsMaxInclusive', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsMinExclusive', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsMaxExclusive', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsEnumeration', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsWhiteSpace', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsPattern', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + + $this->_addAttribute( 'base', array( 'type' => 'xs:string' ) ); + + $this->type[] = 'xsRestriction'; + parent::_elementSet(); + } +} + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.5/om/xsSchema.php b/1.4.0/dom/codeGen/1.5/om/xsSchema.php new file mode 100644 index 0000000..c0b5d8b --- /dev/null +++ b/1.4.0/dom/codeGen/1.5/om/xsSchema.php @@ -0,0 +1,32 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +class xsSchema extends _elementSet +{ + function xsSchema() + { + $this->_addElement( 'xsAnnotation', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsElement', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsSimpleType', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsComplexType', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsGroup', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsImport', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + + $this->_addAttribute( 'targetNamespace', array( 'type' => 'xs:string' ) ); + $this->_addAttribute( 'elementFormDefault', array( 'type' => 'xs:string' ) ); + $this->_addAttribute( 'xmlns:xs', array( 'type' => 'xs:string' ) ); + $this->_addAttribute( 'xmlns', array( 'type' => 'xs:string' ) ); + $this->_addAttribute( 'version', array( 'type' => 'xs:string' ) ); + + $this->type[] = 'xsSchema'; + parent::_elementSet(); + } +} + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.5/om/xsSequence.php b/1.4.0/dom/codeGen/1.5/om/xsSequence.php new file mode 100644 index 0000000..280d253 --- /dev/null +++ b/1.4.0/dom/codeGen/1.5/om/xsSequence.php @@ -0,0 +1,32 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +class xsSequence extends _elementSet +{ + function xsSequence() + { + $this->_addElement( 'xsElement', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsAttribute', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsChoice', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsSequence', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsGroup', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsAny', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + $this->_addElement( 'xsAnnotation', array( 'minOccurs' => '0', 'maxOccurs' => 'unbounded' ) ); + + $this->type[] = "xsSequence"; + parent::_elementSet(); + } + + function addSequenceElement( & $e ) + { + $this->addElement( $e ); + } +} + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.5/om/xsSimpleContent.php b/1.4.0/dom/codeGen/1.5/om/xsSimpleContent.php new file mode 100644 index 0000000..2001cea --- /dev/null +++ b/1.4.0/dom/codeGen/1.5/om/xsSimpleContent.php @@ -0,0 +1,24 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +class xsSimpleContent extends _elementSet +{ + function xsSimpleContent() + { + $this->_addElement( 'xsRestriction', array( 'minOccurs' => '1', 'maxOccurs' => '1' ) ); + $this->_addElement( 'xsExtension', array( 'minOccurs' => '1', 'maxOccurs' => '1' ) ); + +// $this->_addAttribute( 'name', array( 'type' => 'xs:string' ) ); + + $this->type[] = 'xsSimpleContent'; + parent::_elementSet(); + } +} + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.5/om/xsSimpleType.php b/1.4.0/dom/codeGen/1.5/om/xsSimpleType.php new file mode 100644 index 0000000..5b40cbe --- /dev/null +++ b/1.4.0/dom/codeGen/1.5/om/xsSimpleType.php @@ -0,0 +1,143 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +require_once( 'src/TypeMeta.php' ); + +class xsSimpleType extends _elementSet +{ + function xsSimpleType() + { + $this->_addElement( 'xsRestriction', array( 'minOccurs' => '1', 'maxOccurs' => '1' ) ); + $this->_addElement( 'xsExtension', array( 'minOccurs' => '1', 'maxOccurs' => '1' ) ); + $this->_addElement( 'xsList', array( 'minOccurs' => '1', 'maxOccurs' => '1' ) ); + $this->_addElement( 'xsUnion', array( 'minOccurs' => '1', 'maxOccurs' => '1' ) ); + + $this->_addElement( 'xsAnnotation', array( 'minOccurs' => '1', 'maxOccurs' => '1' ) ); + + $this->_addAttribute( 'name', array( 'type' => 'xs:string' ) ); + + $this->type[] = 'xsSimpleType'; + parent::_elementSet(); + } + + function & generate() + { + $vars = array(); + $e = $this->getElements(); + $generator = new TypeMeta(); + + $generator->setType( $this->getAttribute( 'name' ) ); + + $a = $this->getElementsByType( 'xsAnnotation' ); + if ( count( $a ) > 0 ) + { + //print "found annotation for ". $this->getAttribute( 'name' ) ."!\n"; + $d = $a[0]->getElementsByType( 'xsDocumentation' ); + if ( count( $d ) > 0 ) + { + //print "found documentation for ". $this->getAttribute( 'name' ) ."!\n"; + $generator->setDocumentation( $d[0]->get() ); + } + $ap = $a[0]->getElementsByType( 'xsAppinfo' ); + if ( count( $ap ) > 0 ) + { + $generator->setAppInfo( $ap[0]->get() ); + } + } + + $idx = 0; + if ( $e[$idx]->getType() == 'xsAnnotation' ) { + $idx = 1; + } + if ( $e[$idx]->getType() == 'xsRestriction' || $e[$idx]->getType() == 'xsExtension' ) + { + $generator->setIsExtension( $e[$idx]->getType() == 'xsExtension' ); + + // Set base class + $generator->setBase( $e[$idx]->getAttribute( 'base' ) ); + + // Look for enums + $enums = $e[$idx]->getElementsByType( 'xsEnumeration' ); + for( $i=0; $i<count( $enums ); $i++ ) + { + $generator->addEnum( $enums[$i]->getAttribute( 'value' ) ); + $an = $enums[$i]->getElementsByType('xsAnnotation'); + if ( count( $an ) > 0 ) { + $doc = $an[0]->getElementsByType( 'xsDocumentation' ); + if ( count( $doc ) > 0 ) { + $generator->addEnumDoc( $i, $doc[0]->get() ); + } + $ap = $an[0]->getElementsByType( 'xsAppinfo' ); + if ( count( $ap ) > 0 ) + { + $generator->addEnumAppInfo( $i, $ap[0]->get() ); + } + } + } + + // Look for max/mins + $array_limits = array(); + $min = $e[$idx]->getElementsByType( 'xsMinLength' ); + $max = $e[$idx]->getElementsByType( 'xsMaxLength' ); + $minIn = $e[$idx]->getElementsByType( 'xsMinInclusive' ); + $maxIn = $e[$idx]->getElementsByType( 'xsMaxInclusive' ); + $minEx = $e[$idx]->getElementsByType( 'xsMinExclusive' ); + $maxEx = $e[$idx]->getElementsByType( 'xsMaxExclusive' ); + + if ( count( $min ) > 0 ) + { + $generator->setRestriction( 'minLength', $min[0]->getAttribute( 'value' ) ); + } + + if ( count( $max ) > 0 ) + { + $generator->setRestriction( 'maxLength', $max[0]->getAttribute( 'value' ) ); + } + + if ( count( $minIn ) > 0 ) + { + $generator->setRestriction( 'minInclusive', $minIn[0]->getAttribute( 'value' ) ); + } + + if ( count( $maxIn ) > 0 ) + { + $generator->setRestriction( 'maxInclusive', $maxIn[0]->getAttribute( 'value' ) ); + } + + if ( count( $minEx ) > 0 ) + { + $generator->setRestriction( 'minExclusive', $minEx[0]->getAttribute( 'value' ) ); + } + + if ( count( $maxEx ) > 0 ) + { + $generator->setRestriction( 'maxExclusive', $maxEx[0]->getAttribute( 'value' ) ); + } + } else if ( $e[$idx]->getType() == 'xsList' ) + { + //$extends = "xsList"; + $itemType = $e[$idx]->getAttribute( 'itemType' ); + $generator->setListType( $itemType ); + $generator->bag['isArray'] = true; + } + else if ( $e[$idx]->getType() == 'xsUnion' ) { + $generator->setUnionMembers( $e[$idx]->getAttribute( 'memberTypes' ) ); + } + else + { + $this->log( "WARN: unexpected element in xsSimpleType code generation" ); + } + + $meta = & $generator->getMeta(); + return $meta; + } +} + + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.5/om/xsUnion.php b/1.4.0/dom/codeGen/1.5/om/xsUnion.php new file mode 100644 index 0000000..79954ad --- /dev/null +++ b/1.4.0/dom/codeGen/1.5/om/xsUnion.php @@ -0,0 +1,21 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +class xsUnion extends _typedData +{ + function xsUnion() + { + $this->_addAttribute( 'memberTypes', array( 'type' => 'xs:string' ) ); + + $this->type[] = 'xsUnion'; + parent::_typedData(); + } +} + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.5/om/xsWhiteSpace.php b/1.4.0/dom/codeGen/1.5/om/xsWhiteSpace.php new file mode 100644 index 0000000..a968f0e --- /dev/null +++ b/1.4.0/dom/codeGen/1.5/om/xsWhiteSpace.php @@ -0,0 +1,21 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +class xsWhiteSpace extends _typedData +{ + function xsWhiteSpace() + { + $this->_addAttribute( 'value', array( 'type' => 'xs:string' ) ); + + $this->type[] = 'xsWhiteSpace'; + parent::_typedData(); + } +} + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.5/src/ElementMeta.php b/1.4.0/dom/codeGen/1.5/src/ElementMeta.php new file mode 100644 index 0000000..b7b9882 --- /dev/null +++ b/1.4.0/dom/codeGen/1.5/src/ElementMeta.php @@ -0,0 +1,280 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +class ElementMeta +{ + var $pre_name; + var $name; + //var $extends; + var $doc; + + var $bag; + + function ElementMeta( & $global_elements ) + { + $bag = array( + 'has_id_attr' => false, + 'context' => '', + 'pre_name' => '', + 'content_type' => '', + 'base_type' => '', + 'documentation' => array(), + 'element_name' => '', + 'elements' => array(), + 'inline_elements' => array(), + 'ref_elements' => array(), + 'element_attrs' => array(), + 'attributes' => array(), + 'mixed' => false, + 'complex_type' => false, + 'abstract' => false, + 'substitution_group' => '', + 'element_documentation' => array(), + 'useXMLNS' => false, + 'hasChoice' => false, + 'isEmptyContent' => false, + 'groupElements' => array(), + 'isAComplexType' => false, + 'isAGroup' => false, + 'substitutableWith' => array(), + 'isExtension' => false, + 'isRestriction' => false, + 'simple_type' => NULL, + 'parent_meta' => NULL, + 'has_any' => false, + 'content_model' => array() + ); + + $this->bag = & $bag; + $this->bag['global_elements'] = & $global_elements; + } + + function addGroup( & $e ) { + $this->bag['groupElements'][] = $e->getAttribute('ref'); + } + + function setSubstitutionGroup( $subGroup ) { + $this->bag['substitution_group'] = trim( $subGroup ); + } + + function setComplexType( $bool ) { + $this->bag['complex_type'] = ( $bool == true ); + } + + function setAbstract( $bool ) { + $this->bag['abstract'] = ( $bool == true ); + } + + function setHasChoice( $bool ) { + $this->bag['hasChoice'] = $bool; + } + + function setIsEmptyContent( $bool ) { + $this->bag['isEmptyContent'] = $bool; + } + + function setIsAComplexType( $bool ) { + $this->bag['isAComplexType'] = ( $bool == true ); + } + + function setIsAGroup( $bool ) { + $this->bag['isAGroup'] = ( $bool == true ); + } + + function & getMeta() + { + return $this->bag; + } + + function setMixed( $bool ) + { + $this->bag['mixed'] = ( $bool == true ); + } + + function setContentType( $type ) + { + // Strip xs if we've got a built-in type + /*if ( preg_match( "/xs\:/", $type ) ) + { + $type = 'xs' . substr( $type, 3 ); + }*/ + // If type is non-empty, then go ahead and set it + if ( preg_match( "/[^\s]+/", $type ) ) + { + $this->bag['content_type'] = trim( $type ); + } + } + + function setMinOccurs( $min ) + { + if ( is_int( $min ) && $min >= 0 ) + { + $this->bag['minOccurs'] = $min; + } + } + + function setMaxOccurs( $max ) + { + if ( $max == 'unbounded' || (is_int( $max ) && $max >= 1 ) ) + { + $this->bag['maxOccurs'] = $max; + } + } + + function setPreName( $pre ) + { + $this->pre_name = $pre; + $this->bag['pre_name'] = $pre; + } + + function setName( $name ) + { + $this->name = $name; + $this->bag['element_name'] = $name; + } + + function getName() + { + return $this->name; + } + + function setHasID( $bool ) + { + $this->bag['has_id_attr'] = $bool; + } + + function setDocumentation( $doc ) + { + $this->doc = $doc; + $this->bag['documentation']['en'] = trim( $doc ); + } + + function setAppInfo( $ap ) { + if (!strcmp( trim($ap), 'enable-xmlns' ) ) { + //use the xmlns attribute + $this->bag['useXMLNS'] = true; + } + } + + function setContext( $context ) + { + $this->bag['context'] = $context; + } + + function addElement( & $e, $context ) + { + $name = 'undefined'; + $ref_element = false; + $_attributes = array(); + + foreach( $e->getAttributes() as $k => $v ) + { + $_attributes[ $k ] = $v; + + if ( $k == 'ref' ) + { + $name = $v; + $ref_element = true; + } + else if ( $k == 'name' ) + { + $name = $v; + } + } + + //check if this element already exists this only applies if in a sequence. + foreach( $this->bag['elements'] as $nm ) { + if ( $nm == $name ) { + //print "found duplicate element upping max occurs"; + //if it does then update its max occurs and exit + if ( !$this->bag['hasChoice'] || $_attributes['maxOccurs'] == 'unbounded' ) { + if ( $this->bag['element_attrs'][$nm]['maxOccurs'] != 'unbounded' ) { + $this->bag['element_attrs'][$nm]['maxOccurs']++; + } + } + //print " to ". $this->bag['element_attrs'][$nm]['maxOccurs'] ."\n"; + return; + } + } + + // Track the attrs on each sub-element + $this->bag['element_attrs'][ $name ] = & $_attributes; + + // Call the dom-recurse function on each new element + if ( !$ref_element ) + { + $this->bag['elements'][] = $name; + $this->bag['inline_elements'][ $name ] = & $e->generate( $this->bag['context'], $this->bag['global_elements'] ); + $this->bag['element_documentation'][$name] = $this->bag['inline_elements'][ $name ]['documentation']['en']; + $this->bag['inline_elements'][ $name ]['parent_meta'] = & $this->bag; + } + else { + $this->bag['elements'][] = $name; + $this->bag['ref_elements'][] = $name; + //check for documentation + $a = $e->getElementsByType( 'xsAnnotation' ); + if ( count( $a ) > 0 ) { + $d = $a[0]->getElementsByType( 'xsDocumentation' ); + if ( count( $d ) > 0 ) + { + $this->bag['element_documentation'][$name] = $d[0]->get(); + } + } + } + + } + + function addAttribute( & $a ) + { + $name = ''; + $a_list = array(); + + foreach( $a->getAttributes() as $k => $v ) + { + $a_list[ $k ] = $v; + if ( $k == 'name' ) + { + $name = $v; + if ( $name == 'id' ) { $this->bag['has_id_attr'] = true; } + } + else if ( $k == 'ref' ) { + $name = $v; + //printf( "found an attribute ref for ". $name ."\n"); + if ( strpos( $name, ':' ) !== FALSE ) { + $name[strpos( $name, ':' )] = '_'; + //printf( "changed : to _ for ". $name ."\n" ); + $a_list[ 'type' ] = 'xs:anyURI'; + } + } + } + //check for documentation + $e = $a->getElementsByType( 'xsAnnotation' ); + if ( count( $e ) > 0 ) + { + $d = $e[0]->getElementsByType( 'xsDocumentation' ); + if ( count( $d ) > 0 ) + { + $a_list['documentation'] = $d[0]->get(); + } + } + + $this->bag['attributes'][ $name ] = & $a_list; + + //print "adding attribute ". $name ."\n"; + } + + //For elements name is the element name, for sequence name = 0, choice = 1, group = 2, all = 3, any = 4, end = 5 + function addContentModel( $name, $minOccurs, $maxOccurs ) + { + $this->bag['content_model'][] = array( 'name' => $name, 'minOccurs' => $minOccurs, 'maxOccurs' => $maxOccurs ); + print "adding content model name: ". $name ." minO: ". $minOccurs ." maxO: ". $maxOccurs ."\n"; + } +} + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.5/src/SchemaParser.php b/1.4.0/dom/codeGen/1.5/src/SchemaParser.php new file mode 100644 index 0000000..c32bf8d --- /dev/null +++ b/1.4.0/dom/codeGen/1.5/src/SchemaParser.php @@ -0,0 +1,82 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +require_once( 'om/object-model.php' ); + +class SchemaParser +{ + var $parse_stack = array(); + var $root_elements = array(); + var $parser; + + function SchemaParser() + { + $this->parser = xml_parser_create(); + + xml_parser_set_option( $this->parser, XML_OPTION_CASE_FOLDING, false ); + xml_set_object( $this->parser, $this ); + xml_set_element_handler( $this->parser, "startElement", "endElement" ); + xml_set_character_data_handler( $this->parser, "characterData" ); + + //xml_parser_free( $this->parser ); + } + + function startElement( $parser, $name, $attrs ) + { + if ( preg_match( "/xs\:/", $name ) ) + { + $class_name = substr( $name, 3 ); + $class_name = 'xs' . ucfirst( $class_name ); + + eval( '$e = new ' . $class_name . '();' ); + foreach( $attrs as $k => $v ) { $e->setAttribute( $k, $v ); } + + if ( count( $this->parse_stack ) > 0 ) + { + $stackSize = count( $this->parse_stack ); + $parentElement = & $this->parse_stack[ $stackSize - 1 ]; + $parentElement->addElement( $e ); + } else + { + $this->root_elements[] = & $e; + } + $this->parse_stack[] = & $e; + } + } + + function endElement( $parser, $name ) + { + $pop = & array_pop( $this->parse_stack ); + } + + function characterData( $parser, $data ) + { + if ( count( $this->parse_stack ) > 0 ) + { + $this->parse_stack[ count( $this->parse_stack ) - 1 ]->append( $data ); + } + } + + function parse( $file ) + { + if ( file_exists( $file ) ) + { + if ( !xml_parse( $this->parser, file_get_contents( $file ) ) ) + { + // Got parse error + } + } else + { + // Bad file + } + } + +} + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.5/src/TypeMeta.php b/1.4.0/dom/codeGen/1.5/src/TypeMeta.php new file mode 100644 index 0000000..f7f46fc --- /dev/null +++ b/1.4.0/dom/codeGen/1.5/src/TypeMeta.php @@ -0,0 +1,108 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +class TypeMeta +{ + var $bag; + + function TypeMeta() + { + $bag = array( + 'type' => '', + 'base' => '', + 'listType' => '', + 'enum' => array(), + 'enum_documentation' => array(), + 'restrictions' => array(), + 'isExtension' => true, + 'isComplex' => false, + 'useConstStrings' =>false, + 'documentation' => array(), + 'isArray' => false, + 'enum_value' => array(), + 'union_type' => false, + 'union_members' => '' + ); + $this->bag = & $bag; + } + + function & getMeta() + { + return $this->bag; + } + + function setType( $t ) + { + $this->bag['type'] = $t; + } + + function setBase( $b ) + { + $this->bag['base'] = $b; + } + + function setListType( $type ) + { + $this->bag['listType'] = $type; + } + + function setIsExtension( $bool ) + { + $this->bag['isExtension'] = $bool; + } + + function setIsComplex( $bool ) { + $this->bag['isComplex'] = $bool; + } + + function setRestriction( $name, $val ) + { + $this->bag['restrictions'][$name] = $val; + } + + function addEnum( $val ) + { + $this->bag['enum'][] = $val; + } + + function setAppInfo( $ap ) { + if (!strcmp( trim($ap), 'constant-strings' ) ) { + //use the xmlns attribute + $this->bag['useConstStrings'] = true; + } + } + + function setDocumentation( $doc ) + { + $this->doc = $doc; + $this->bag['documentation']['en'] = trim( $doc ); + } + + function addEnumDoc( $i, $doc ) { + $this->bag['enum_documentation'][$i] = trim($doc); + } + + function addEnumAppInfo( $i, $ai ) { + $ai = trim($ai); + //print "found app info\n"; + if ( strncmp($ai, "value=", 6) == 0 ) { + //print "its in the correct format\n"; + $val = substr($ai, 6); + //print "value is ". $val ."\n"; + $this->bag['enum_value'][$i] = trim($val); + } + } + + function setUnionMembers( $um ) { + $this->bag['union_type'] = true; + $this->bag['union_members'] = $um; + } +} + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.5/tpl/template-engine.php b/1.4.0/dom/codeGen/1.5/tpl/template-engine.php new file mode 100644 index 0000000..317d3a1 --- /dev/null +++ b/1.4.0/dom/codeGen/1.5/tpl/template-engine.php @@ -0,0 +1,726 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +$_globals = array(); +// FLAG: Full Code - set true to output verbose mode, minimal otherwise (does not include// inline elements in minimal) +$_globals['full_code'] = true; +$_globals['copyright'] = false; +$_globals['copyright_text'] = "/*\n" . +" * Copyright 2006 Sony Computer Entertainment Inc.\n" . +" *\n" . +" * Licensed under the SCEA Shared Source License, Version 1.0 (the \"License\"); you may not use this\n" . +" * file except in compliance with the License. You may obtain a copy of the License at:\n" . +" * http://research.scea.com/scea_shared_source_license.html\n" . +" *\n" . +" * Unless required by applicable law or agreed to in writing, software distributed under the License\n" . +" * is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n" . +" * implied. See the License for the specific language governing permissions and limitations under the\n" . +" * License.\n" . +" */\n\n"; + +$_globals['depth'] = 0; +$_globals['meta_prefix'] = 'dae'; +$_globals['prefix'] = 'dom'; +$_globals['language'] = 'en'; +$_globals['dom_dir'] = 'gen/dom/'; +$_globals['tmp_dir'] = 'tmp/'; +$_globals['log_file'] = 'gen/gen.log'; + +$_globals['register_list'] = array(); +$_globals['include_list'] = array(); +$_globals['complex_types'] = array(); +$_globals['groups'] = array(); +$_globals['constStrings'] = array(); //used to store all the constant strings needed to be put in the file. +$_globals['elementTypes'] = array(); +$_globals['elementNames'] = array(); +$_globals['elementNames'][] = "COLLADA"; //needed because no elements have this as a child. +$_globals['typeID'] = 0; + +$_globals['target_dir'] = ''; + +$_globals['global_elements'] = array(); + +$_globals['templates'] = array( + 'DOXYGEN' => 'tpl/tpl-doxygen.php', + 'TYPES_HEADER_FILE' => 'tpl/tpl-types-header-file.php', + 'TYPES_HEADER' => 'tpl/tpl-types-header.php', + 'TYPES_CPP_FILE' => 'tpl/tpl-types-cpp-file.php', + 'TYPES_CPP' => 'tpl/tpl-types-cpp.php', + 'INCLUDES' => 'tpl/tpl-includes.php', + 'HEADER' => 'tpl/tpl-dot-h.php', + 'HEADER_FILE' => 'tpl/tpl-header.php', + 'INCLUDE_LIST' => 'tpl/tpl-include-list.php', + 'CPP_FILE' => 'tpl/tpl-cpp.php', + 'CPP' => 'tpl/tpl-cpp-body.php', + 'CPP_STATIC' => 'tpl/tpl-cpp-static.php', + 'CPP_METHODS' => 'tpl/tpl-cpp-methods.php', + 'CLASS' => 'tpl/tpl-class-def.php', + 'ELEMENTS_FILE' => 'tpl/tpl-elements-file.php', + 'ELEMENTS' => 'tpl/tpl-elements.php', + 'CONSTANTS_FILE' => 'tpl/tpl-constants-file.php', + 'CONSTANTS' => 'tpl/tpl-constants.php', + 'CONSTANTS_CPP_FILE' => 'tpl/tpl-constants-cpp-file.php', + 'CONSTANTS_CPP' => 'tpl/tpl-constants-cpp.php' +); + + +function getTypeNameAndPrefix(&$typeName, &$prefix) { + global $_globals; + if(preg_match( "/xs\:/", $typeName)) { + $typeName = substr( $typeName, 3 ); + $prefix = "xs"; + } + else + $prefix = $_globals['prefix']; +} + +function applyTemplate( $template, & $bag ) +{ + global $_globals; + + $_result = ''; + if ( array_key_exists( $template, $_globals['templates'] ) ) + { + ob_start(); + include( $_globals['templates'][ $template ] ); + + $_result = ob_get_contents(); + ob_end_clean(); + } + return $_result; +} + +function initGen( $file ) +{ + global $_globals; + + // A few defns + $_globals['gen_start_time'] = date( "M d Y H:i:s" ); + $_globals['file_name'] = $file; + + // Verify target dirs exist, create if not + makeGenDir( getcwd() . "/gen" ); + makeGenDir( getcwd() . "/" . $_globals['dom_dir'] ); + makeGenDir( getcwd() . "/" . $_globals['dom_dir'] . 'include/' ); + makeGenDir( getcwd() . "/" . $_globals['dom_dir'] . 'src/' ); + + // Start buffering output + ob_start(); +} + +function makeGenDir( $dir ) +{ + if ( !is_dir( $dir ) ) + { + if ( !mkdir( $dir ) ) + { + die( "Could not create directory $dir\n" ); + } + } +} + +function cleanupGen() +{ + global $_globals; + + // Get output buffer + $_result = ob_get_contents(); + ob_end_clean(); + // Assemble report + ob_start(); + print "========================================\n\n"; + print " Code Generation\n\n"; + print "----------------------------------------\n"; + print "COLLADA File: " . $_globals['file_name'] . "\n"; + print "Start time: " . $_globals['gen_start_time'] . "\n"; + print "End time: " . date( "M d Y H:i:s" ) . "\n"; + print "----------------------------------------\n\n"; + print $_result; + print "\r\n\r\nend\r\n"; + file_put_contents( $_globals['log_file'], ob_get_contents() ); + ob_end_clean(); + print "Generation complete\n"; +} + +function saveTemplate( $file, $template, & $bag ) +{ + $bytes = file_put_contents( $file, applyTemplate( $template, $bag ) ); +} + +function printAllSubChildren( & $elem, $prefix, $suffix ) { + //print "subchild test count = ". count( $elem['elements'] ) ."\n"; + //print "subchild test name = ". $elem['element_name'] ."\n"; + global $_globals; + global $meta; + for ( $i = 0; $i < count( $elem['elements'] ); $i++ ) { + if ( isset( $meta[$elem['elements'][$i]] ) ) { + if ( $meta[$elem['elements'][$i]]['isAGroup'] ) { + + printAllSubChildren( $meta[$elem['elements'][$i]], $prefix, $suffix ); + } + else if ( !$meta[$elem['elements'][$i]]['abstract'] ) { + print $prefix ."_Meta->children.append(\"". $elem['elements'][$i] ."\");". $suffix; + print ");\n"; + } + for( $c = 0; $c < count( $meta[$elem['elements'][$i]]['substitutableWith']); $c++ ) { + $subwith = $meta[$elem['elements'][$i]]['substitutableWith'][$c]; + print $prefix ."_Meta->children.append(\"". $subwith ."\");". $suffix; + print ");\n"; + } + } + else { + print $prefix . $elem['elements'][$i] . $suffix; + if ( isset($meta[$elem['element_attrs'][ $elem['elements'][$i] ]['type']]) && + $meta[$elem['element_attrs'][ $elem['elements'][$i] ]['type']]['isAComplexType'] ) { + print ", \"". $elem['element_attrs'][ $elem['elements'][$i] ]['type'] ."\""; + } + print ");\n"; + } + } +} + +function getInheritanceStatement($baseClasses) { + if (count($baseClasses) == 0) + return ""; + $statement = " : public " . $baseClasses[0]; + for ($i = 1; $i < count($baseClasses); $i++) + $statement .= ", public " . $baseClasses[$i]; + return $statement; +} + +function beginConstructorInitializer(& $initializerListStarted) { + print $initializerListStarted ? ", " : " : "; + $initializerListStarted = true; +} + +function printBaseClassInitializers($elemName, $baseClass, & $initializerListStarted) { + beginConstructorInitializer($initializerListStarted); + print $baseClass . "(dae)"; +} + +function printConstructors( $elemName, & $bag, $baseClass, $indent ) { + //print the protected ctor and copy stuff + print $indent ."protected:\n"; + print $indent ."\t/**\n". $indent ."\t * Constructor\n". $indent ."\t */\n"; + print $indent ."\t". $elemName ."(DAE& dae)"; + $initializerListStarted = false; + $eltVar = "*this"; + + printBaseClassInitializers($elemName, $baseClass, $initializerListStarted); + + if ($bag['useXMLNS']) { + beginConstructorInitializer($initializerListStarted); + print "attrXmlns(dae, " . $eltVar . ")"; + } + + // Constructor initialization of attributes + if (count($bag['attributes']) > 0) { + foreach( $bag['attributes'] as $attr_name => & $a_list ) { + beginConstructorInitializer($initializerListStarted); + + $attr_name = ucfirst($attr_name); + $type = $a_list['type']; + print "attr" . $attr_name . "("; + if ($type == 'xs:anyURI' || $type == 'urifragment') + print "dae, " . $eltVar; + else if ($type == 'xs:IDREF') + print $eltVar; + else if ($type == 'xs:IDREFS') + print "new xsIDREF(" . $eltVar . ")"; + print ")"; + } + } + + // Constructor initialization of elements + for( $i=0; $i<count( $bag['elements'] ); $i++ ) { + $maxOccurs = $bag['element_attrs'][ $bag['elements'][$i] ]['maxOccurs']; + $maxOccurs = ($maxOccurs == 'unbounded' || $maxOccurs > 1); + beginConstructorInitializer($initializerListStarted); + print "elem" . ucfirst($bag['elements'][$i]) . ($maxOccurs ? "_array" : "") . "()"; + } + + if (!isset($bag['baseTypeViaRestriction'])) { + if ( ($bag['content_type'] != '' || $bag['mixed']) && !$bag['abstract'] ) { + beginConstructorInitializer($initializerListStarted); + if ($bag['content_type'] == 'xs:anyURI' || $bag['content_type'] == 'urifragment') + print "_value(dae, " . $eltVar . ")"; + else if ($bag['content_type'] == 'xs:IDREF') + print "_value(" . $eltVar . ")"; + else if ($bag['content_type'] == 'xs:IDREFS') + print "_value(new xsIDREF(" . $eltVar . "))"; + else + print "_value()"; + } + } + print " {}\n"; + + print $indent ."\t/**\n". $indent ."\t * Destructor\n". $indent ."\t */\n"; + print $indent ."\tvirtual ~". $elemName ."() {"; + if ( $bag['hasChoice'] ) { + print " daeElement::deleteCMDataArray(_CMData); "; + } + print "}\n"; + + print $indent ."\t/**\n". $indent ."\t * Overloaded assignment operator\n". $indent ."\t */\n"; + print $indent ."\tvirtual ".$elemName ." &operator=( const ".$elemName ." &cpy ) { (void)cpy; return *this; }\n"; +} + +function printElements(&$bag, &$needsContents, &$indent) { + global $_globals; + global $meta; + if ( (count( $bag['elements'] ) > 0 && !$bag['isRestriction']) || $bag['has_any'] ) + { + + print $indent ."protected: // Element". (count( $bag['elements'] ) > 1 ? 's' : '') ."\n"; + $needsContents = false; + for( $i=0; $i<count( $bag['elements'] ); $i++ ) + { + $maxOccurs = $bag['element_attrs'][ $bag['elements'][$i] ]['maxOccurs']; + // $minOccurs = $bag['element_attrs'][ $bag['elements'][$i] ]['minOccurs']; + // print " // minOccurs=$minOccurs, maxOccurs=$maxOccurs\n"; + $maxOccurs = ($maxOccurs == 'unbounded' || $maxOccurs > 1); + if ( isset( $bag['element_documentation'][ $bag['elements'][$i] ] ) ) { + $bag['element_documentation'][ $bag['elements'][$i] ] .= " @see " . $_globals['prefix'] . ucfirst( $bag['elements'][$i] ); + print applyTemplate( 'DOXYGEN', $bag['element_documentation'][ $bag['elements'][$i] ] ); + } + if ( isset( $bag['element_attrs'][ $bag['elements'][$i] ]['type'] ) && + isset( $meta[$bag['element_attrs'][ $bag['elements'][$i] ]['type']] ) ){ + print $indent ."\t" . $_globals['prefix'] . ucfirst( $bag['element_attrs'][ $bag['elements'][$i] ]['type'] ) . ($maxOccurs ? "_Array" : "Ref") . " elem" . ucfirst($bag['elements'][$i]) . ($maxOccurs ? "_array" : "") . ";\n"; + } + else { + print $indent ."\t" . $_globals['prefix'] . ucfirst( $bag['elements'][$i] ) . ($maxOccurs ? "_Array" : "Ref") . " elem" . ucfirst($bag['elements'][$i]) . ($maxOccurs ? "_array" : "") . ";\n"; + } + if ( isset( $meta[$bag['elements'][$i]] ) ) { + if( count( $meta[$bag['elements'][$i]]['substitutableWith']) > 0 ) { + $needsContents = true; + } + } + } + if ( $bag['hasChoice'] || $needsContents || $bag['has_any'] ) + { + print $indent ."\t/**\n". $indent ."\t * Used to preserve order in elements that do not specify strict sequencing of sub-elements."; + print "\n". $indent ."\t */\n"; + print $indent ."\tdaeElementRefArray _contents;\n"; + print $indent ."\t/**\n". $indent ."\t * Used to preserve order in elements that have a complex content model."; + print "\n". $indent ."\t */\n"; + print $indent ."\tdaeUIntArray _contentsOrder;\n\n"; + } + if ( $bag['hasChoice'] ) + { + print $indent ."\t/**\n". $indent ."\t * Used to store information needed for some content model objects.\n"; + print $indent ."\t */\n". $indent ."\tdaeTArray< daeCharArray * > _CMData;\n\n"; + } + } +} + +function printAttributes( & $bag, & $typemeta, & $indent, $vaa ) { + global $_globals; + + $attrCnt = 0; + if ( $bag['useXMLNS'] ) { + //comment + print $indent ."\t/**\n". $indent ."\t * Gets the xmlns attribute.\n"; + print $indent ."\t * @return Returns a xsAnyURI reference of the xmlns attribute.\n"; + print $indent ."\t */\n"; + //code + print $indent ."\txsAnyURI &getXmlns() { return attrXmlns; }\n"; + //comment + print $indent ."\t/**\n". $indent ."\t * Gets the xmlns attribute.\n"; + print $indent ."\t * @return Returns a constant xsAnyURI reference of the xmlns attribute.\n"; + print $indent ."\t */\n"; + //code + print $indent ."\tconst xsAnyURI &getXmlns() const { return attrXmlns; }\n"; + //comment + print $indent ."\t/**\n". $indent ."\t * Sets the xmlns attribute.\n"; + print $indent ."\t * @param xmlns The new value for the xmlns attribute.\n"; + print $indent ."\t */\n"; + //code + print $indent ."\tvoid setXmlns( const xsAnyURI &xmlns ) { attrXmlns = xmlns;"; + if ( $vaa ) { + print $indent ."\n\t _validAttributeArray[". $attrCnt ."] = true;"; + } + print " }\n\n"; + + $attrCnt++; + } + + foreach( $bag['attributes'] as $attr_name => & $a_list ) { + $type = $a_list['type']; + $pre = ''; + getTypeNameAndPrefix($type, $pre); + if ( $type == '' ) + { + $type = "String"; + } + $baseStringTypes = "xsDateTime xsID xsNCName xsNMTOKEN xsName xsToken xsString domSidref domSid"; + $baseType = $pre . ucfirst( $type ); + if ( isset( $typemeta[$type] ) ) { + $typeInfo = $typemeta[$type]; + while ( $typeInfo['base'] != '' && isset( $typemeta[$typeInfo['base']] ) ) { + $typeInfo = $typemeta[$typeInfo['base']]; + if ( preg_match( "/xs\:/", $typeInfo['type'] ) ) { + $baseType = "xs" . ucfirst( substr( $typeInfo['type'], 3 ) ); + } + else { + $baseType = $_globals['prefix'] . ucfirst( $typeInfo['type'] ); + } + } + } + + if ( (isset( $typemeta[$type] ) && $typemeta[$type]['isArray']) || $type == 'IDREFS' ) { + //comment + print $indent ."\t/**\n". $indent ."\t * Gets the ". $attr_name ." array attribute.\n"; + print $indent ."\t * @return Returns a ". $pre . ucfirst( $type ) ." reference of the ". $attr_name ." array attribute.\n"; + print $indent ."\t */\n"; + //code + print $indent ."\t" . $pre . ucfirst( $type ) . " &get" . ucfirst($attr_name) ."() { "; + print "return attr". ucfirst($attr_name) ."; }\n"; + //comment + print $indent ."\t/**\n". $indent ."\t * Gets the ". $attr_name ." array attribute.\n"; + print $indent ."\t * @return Returns a constant ". $pre . ucfirst( $type ) ." reference of the ". $attr_name ." array attribute.\n"; + print $indent ."\t */\n"; + //code + print $indent ."\tconst " . $pre . ucfirst( $type ) . " &get" . ucfirst($attr_name) ."() const { "; + print "return attr". ucfirst($attr_name) ."; }\n"; + //comment + print $indent ."\t/**\n". $indent ."\t * Sets the ". $attr_name ." array attribute.\n"; + print $indent ."\t * @param at". ucfirst($attr_name)." The new value for the ". $attr_name ." array attribute.\n"; + print $indent ."\t */\n"; + //code + print $indent ."\tvoid set". ucfirst( $attr_name ) ."( const ". $pre . ucfirst( $type ) ." &at"; + print ucfirst($attr_name) ." ) { attr". ucfirst($attr_name) ." = at". ucfirst($attr_name) .";"; + if ( $vaa ) { + print " _validAttributeArray[". $attrCnt ."] = true;"; + } + print " }\n\n"; + } + else if ( ucfirst($type) == 'AnyURI' || ucfirst($type) == 'urifragment' ) { + //comment + print $indent ."\t/**\n". $indent ."\t * Gets the ". $attr_name ." attribute.\n"; + print $indent ."\t * @return Returns a ". $pre . ucfirst( $type ) ." reference of the ". $attr_name ." attribute.\n"; + print $indent ."\t */\n"; + //code + print $indent ."\t" . $pre . ucfirst( $type ) . " &get" . ucfirst($attr_name) ."() { "; + print "return attr". ucfirst($attr_name) ."; }\n"; + //comment + print $indent ."\t/**\n". $indent ."\t * Gets the ". $attr_name ." attribute.\n"; + print $indent ."\t * @return Returns a constant ". $pre . ucfirst( $type ) ." reference of the ". $attr_name ." attribute.\n"; + print $indent ."\t */\n"; + //code + print $indent ."\tconst " . $pre . ucfirst( $type ) . " &get" . ucfirst($attr_name) ."() const { "; + print "return attr". ucfirst($attr_name) ."; }\n"; + //comment + print $indent ."\t/**\n". $indent ."\t * Sets the ". $attr_name ." attribute.\n"; + print $indent ."\t * @param at". ucfirst($attr_name)." The new value for the ". $attr_name ." attribute.\n"; + print $indent ."\t */\n"; + //code + print $indent ."\tvoid set". ucfirst( $attr_name ) ."( const ". $pre . ucfirst( $type ) ." &at"; + print ucfirst($attr_name) ." ) { attr". ucfirst($attr_name) ." = at". ucfirst($attr_name) .";"; + if ( $vaa ) { + print " _validAttributeArray[". $attrCnt ."] = true;"; + } + print " }\n"; + // We add a setter that takes a plain string to help with backward compatibility + //comment + print $indent ."\t/**\n". $indent ."\t * Sets the ". $attr_name ." attribute.\n"; + print $indent ."\t * @param at". ucfirst($attr_name)." The new value for the ". $attr_name ." attribute.\n"; + print $indent ."\t */\n"; + //code + print $indent ."\tvoid set". ucfirst( $attr_name ) ."( xsString at"; + print ucfirst($attr_name) ." ) { attr". ucfirst($attr_name) ." = at" . ucfirst($attr_name) . ";"; + if ( $vaa ) { + print " _validAttributeArray[". $attrCnt ."] = true;"; + } + print " }\n\n"; + } + else if( ucfirst($type) == 'IDREF' ) { + //comment + print $indent ."\t/**\n". $indent ."\t * Gets the ". $attr_name ." attribute.\n"; + print $indent ."\t * @return Returns a ". $pre . ucfirst( $type ) ." reference of the ". $attr_name ." attribute.\n"; + print $indent ."\t */\n"; + //code + print $indent ."\t" . $pre . ucfirst( $type ) . " &get" . ucfirst($attr_name) ."() { "; + print "return attr". ucfirst($attr_name) ."; }\n"; + //comment + print $indent ."\t/**\n". $indent ."\t * Gets the ". $attr_name ." attribute.\n"; + print $indent ."\t * @return Returns a constant ". $pre . ucfirst( $type ) ." reference of the ". $attr_name ." attribute.\n"; + print $indent ."\t */\n"; + //code + print $indent ."\tconst " . $pre . ucfirst( $type ) . " &get" . ucfirst($attr_name) ."() const{ "; + print "return attr". ucfirst($attr_name) ."; }\n"; + //comment + print $indent ."\t/**\n". $indent ."\t * Sets the ". $attr_name ." attribute.\n"; + print $indent ."\t * @param at". ucfirst($attr_name)." The new value for the ". $attr_name ." attribute.\n"; + print $indent ."\t */\n"; + //code + print $indent ."\tvoid set". ucfirst( $attr_name ) ."( const ". $pre . ucfirst( $type ) ." &at"; + print ucfirst($attr_name) ." ) { attr". ucfirst($attr_name) ." = at". ucfirst($attr_name) .";"; + if ( $vaa ) { + print " _validAttributeArray[". $attrCnt ."] = true;"; + } + print " }\n\n"; + } + else if ( strstr( $baseStringTypes, $baseType ) !== FALSE && count( $a_list['enum'] ) == 0 ) { + //comment + print $indent ."\t/**\n". $indent ."\t * Gets the ". $attr_name ." attribute.\n"; + print $indent ."\t * @return Returns a ". $pre . ucfirst( $type ) ." of the ". $attr_name ." attribute.\n"; + print $indent ."\t */\n"; + //code + print $indent ."\t" . $pre . ucfirst( $type ) . " get" . ucfirst($attr_name) ."() const { "; + print "return attr". ucfirst($attr_name) ."; }\n"; + //comment + print $indent ."\t/**\n". $indent ."\t * Sets the ". $attr_name ." attribute.\n"; + print $indent ."\t * @param at". ucfirst($attr_name)." The new value for the ". $attr_name ." attribute.\n"; + print $indent ."\t */\n"; + //code + print $indent ."\tvoid set". ucfirst( $attr_name ) ."( ". $pre . ucfirst( $type ) ." at"; + print ucfirst($attr_name) ." ) { *(daeStringRef*)&attr". ucfirst($attr_name) ." = at". ucfirst($attr_name) .";"; + if ( $vaa ) { + print " _validAttributeArray[". $attrCnt ."] = true; "; + } + if ( $attr_name == "id" ) + { + print "\n". $indent ."\t\tif( _document != NULL ) _document->changeElementID( this, attrId );\n". $indent ."\t"; + } + + print "}\n\n"; + } + else { + //comment + print $indent ."\t/**\n". $indent ."\t * Gets the ". $attr_name ." attribute.\n"; + print $indent ."\t * @return Returns a ". $pre . ucfirst( $type ) ." of the ". $attr_name ." attribute.\n"; + print $indent ."\t */\n"; + //code + print $indent ."\t" . $pre . ucfirst( $type ) . " get" . ucfirst($attr_name) ."() const { "; + print "return attr". ucfirst($attr_name) ."; }\n"; + //comment + print $indent ."\t/**\n". $indent ."\t * Sets the ". $attr_name ." attribute.\n"; + print $indent ."\t * @param at". ucfirst($attr_name)." The new value for the ". $attr_name ." attribute.\n"; + print $indent ."\t */\n"; + //code + print $indent ."\tvoid set". ucfirst( $attr_name ) ."( ". $pre . ucfirst( $type ) ." at"; + print ucfirst($attr_name) ." ) { attr". ucfirst($attr_name) ." = at". ucfirst($attr_name) .";"; + if ( $vaa ) { + print " _validAttributeArray[". $attrCnt ."] = true;"; + } + print " }\n\n"; + } + $attrCnt++; + } +} + +function printAccessorsAndMutators(&$bag, &$needsContents, &$indent) { + global $_globals; + global $meta; + + $content_type = $bag['content_type']; + $pre = ''; + getTypeNameAndPrefix($content_type, $pre); + + if ( $_globals['accessorsAndMutators'] && ( $bag['useXMLNS'] || count($bag['attributes'])>0 || + count($bag['elements'])>0 ||( ($bag['content_type'] != '' || $bag['mixed']) && !$bag['abstract'] ) ) ) { + + //generate accessors and mutators for everything + print "\n". $indent ."public:\t//Accessors and Mutators\n"; + + if($bag['isExtension']) { + printAttributes($meta[$bag['base_type']], $typemeta, $indent, !$meta[$bag['base_type']]['isAComplexType']); + } + + printAttributes( $bag, $typemeta, $indent, !$bag['isAComplexType'] ); + + for( $i=0; $i<count( $bag['elements'] ); $i++ ) { + $maxOccurs = $bag['element_attrs'][ $bag['elements'][$i] ]['maxOccurs']; + $maxOccurs = ($maxOccurs == 'unbounded' || $maxOccurs > 1); + $type = ''; + if ( isset( $bag['element_attrs'][ $bag['elements'][$i] ]['type'] ) && + isset( $meta[$bag['element_attrs'][ $bag['elements'][$i] ]['type']] ) ){ + + $type = $_globals['prefix'] . ucfirst( $bag['element_attrs'][ $bag['elements'][$i] ]['type'] ) . ($maxOccurs ? "_Array" : "Ref"); + } + else { + $type = $_globals['prefix'] . ucfirst( $bag['elements'][$i] ) . ($maxOccurs ? "_Array" : "Ref"); + } + $name = ucfirst($bag['elements'][$i]) . ($maxOccurs ? "_array" : ""); + if ( $maxOccurs ) { + //comment + print $indent ."\t/**\n". $indent ."\t * Gets the ". $bag['elements'][$i] ." element array.\n"; + print $indent ."\t * @return Returns a reference to the array of ". $bag['elements'][$i] ." elements.\n"; + print $indent ."\t */\n"; + //code + print $indent ."\t". $type ." &get". $name ."() { return elem". $name ."; }\n"; + //comment + print $indent ."\t/**\n". $indent ."\t * Gets the ". $bag['elements'][$i] ." element array.\n"; + print $indent ."\t * @return Returns a constant reference to the array of ". $bag['elements'][$i] ." elements.\n"; + print $indent ."\t */\n"; + //code + print $indent ."\tconst ". $type ." &get". $name ."() const { return elem". $name ."; }\n"; + //print $indent ."\tvoid set". $name ."( ". $type ." *e". $name ." ) { elem". $name ." = *e". $name ."; }\n\n"; + } + else { + //comment + print $indent ."\t/**\n". $indent ."\t * Gets the ". $bag['elements'][$i] ." element.\n"; + print $indent ."\t * @return a daeSmartRef to the ". $bag['elements'][$i] ." element.\n"; + print $indent ."\t */\n"; + //code + print $indent ."\tconst ". $type ." get". $name ."() const { return elem". $name ."; }\n"; + //print $indent ."\tvoid set". $name ."( ". $type ." &e". $name ." ) { elem". $name ." = e". $name ."; }\n\n"; + } + + if ( isset( $meta[$bag['elements'][$i]] ) ) { + if( count( $meta[$bag['elements'][$i]]['substitutableWith']) > 0 ) { + $needsContents = true; + } + } + } + + if ( $bag['hasChoice'] || $needsContents || $bag['has_any'] ) + { + //comment + print $indent ."\t/**\n". $indent ."\t * Gets the _contents array.\n"; + print $indent ."\t * @return Returns a reference to the _contents element array.\n"; + print $indent ."\t */\n"; + //code + print $indent ."\tdaeElementRefArray &getContents() { return _contents; }\n"; + //comment + print $indent ."\t/**\n". $indent ."\t * Gets the _contents array.\n"; + print $indent ."\t * @return Returns a constant reference to the _contents element array.\n"; + print $indent ."\t */\n"; + //code + print $indent ."\tconst daeElementRefArray &getContents() const { return _contents; }\n\n"; + } + + if ( ($bag['content_type'] != '' || $bag['mixed']) && !$bag['abstract'] ) + { + $type = $content_type; + if($meta[$content_type]['isAComplexType']) + $type = $type . "Ref"; + $baseStringTypes = "xsDateTime xsID xsNCName xsNMTOKEN xsName xsToken xsString domSidref domSid"; + $baseType = $pre . ucfirst( $type ); + if ( isset( $typemeta[$type] ) ) { + $typeInfo = $typemeta[$type]; + while ( $typeInfo['base'] != '' && isset( $typemeta[$typeInfo['base']] ) ) { + $typeInfo = $typemeta[$typeInfo['base']]; + if ( preg_match( "/xs\:/", $typeInfo['type'] ) ) { + $baseType = "xs" . ucfirst( substr( $typeInfo['type'], 3 ) ); + } + else { + $baseType = $_globals['prefix'] . ucfirst( $typeInfo['type'] ); + } + } + } + //if ( !strcmp( $pre . ucfirst( $type ), $full_element_name ) ) { + if ( $bag['parent_meta']['inline_elements'] != NULL && array_key_exists( $type, $bag['parent_meta']['inline_elements'] ) ) { + $pre = '::' . $pre; + } + if (!isset($bag['baseTypeViaRestriction'])) { + if ( (isset( $typemeta[$content_type] ) && $typemeta[$content_type]['isArray']) || $content_type == 'IDREFS' ) { + //comment + print $indent ."\t/**\n". $indent ."\t * Gets the _value array.\n"; + print $indent ."\t * @return Returns a ". $pre . ucfirst( $type ) ." reference of the _value array.\n"; + print $indent ."\t */\n"; + //code + print $indent ."\t".$pre . ucfirst( $type ) ." &getValue() { return _value; }\n"; + //comment + print $indent ."\t/**\n". $indent ."\t * Gets the _value array.\n"; + print $indent ."\t * @return Returns a constant ". $pre . ucfirst( $type ) ." reference of the _value array.\n"; + print $indent ."\t */\n"; + //code + print $indent ."\tconst ".$pre . ucfirst( $type ) ." &getValue() const { return _value; }\n"; + //comment + print $indent ."\t/**\n". $indent ."\t * Sets the _value array.\n"; + print $indent ."\t * @param val The new value for the _value array.\n"; + print $indent ."\t */\n"; + //code + print $indent ."\tvoid setValue( const ". $pre . ucfirst( $type ) ." &val ) { _value = val; }\n\n"; + //print $indent ."\t _meta->getValueAttribute()->setIsValid(true); }\n\n"; + } + else if ( ucfirst($type) == 'AnyURI' ) { + //comment + print $indent ."\t/**\n". $indent ."\t * Gets the value of this element.\n"; + print $indent ."\t * @return Returns a ". $pre . ucfirst( $type ) ." of the value.\n"; + print $indent ."\t */\n"; + //code + print $indent ."\t".$pre . ucfirst( $type ) ." &getValue() { return _value; }\n"; + //comment + print $indent ."\t/**\n". $indent ."\t * Gets the value of this element.\n"; + print $indent ."\t * @return Returns a constant ". $pre . ucfirst( $type ) ." of the value.\n"; + print $indent ."\t */\n"; + //code + print $indent ."\tconst ".$pre . ucfirst( $type ) ." &getValue() const { return _value; }\n"; + //comment + print $indent ."\t/**\n". $indent ."\t * Sets the _value of this element.\n"; + print $indent ."\t * @param val The new value for this element.\n"; + print $indent ."\t */\n"; + //code + print $indent ."\tvoid setValue( const ". $pre . ucfirst( $type ) ." &val ) { _value = val; }\n"; + // We add a setter that takes a plain string to help with backward compatibility + //comment + print $indent ."\t/**\n". $indent ."\t * Sets the _value of this element.\n"; + print $indent ."\t * @param val The new value for this element.\n"; + print $indent ."\t */\n"; + //code + print $indent ."\tvoid setValue( xsString val ) { _value = val; }\n\n"; + } + else if( ucfirst($type) == 'IDREF' ) { + //comment + print $indent ."\t/**\n". $indent ."\t * Gets the value of this element.\n"; + print $indent ."\t * @return Returns a ". $pre . ucfirst( $type ) ." of the value.\n"; + print $indent ."\t */\n"; + //code + print $indent ."\t".$pre . ucfirst( $type ) ." &getValue() { return _value; }\n"; + //comment + print $indent ."\t/**\n". $indent ."\t * Gets the value of this element.\n"; + print $indent ."\t * @return Returns a constant ". $pre . ucfirst( $type ) ." of the value.\n"; + print $indent ."\t */\n"; + //code + print $indent ."\tconst ".$pre . ucfirst( $type ) ." &getValue() const { return _value; }\n"; + //comment + print $indent ."\t/**\n". $indent ."\t * Sets the _value of this element.\n"; + print $indent ."\t * @param val The new value for this element.\n"; + print $indent ."\t */\n"; + //code + print $indent ."\tvoid setValue( const ". $pre . ucfirst( $type ) ." &val ) { _value = val; }\n\n"; + //print $indent ."\t _meta->getValueAttribute()->setIsValid(true); }\n\n"; + } + else if ( strstr( $baseStringTypes, $baseType ) !== FALSE && count( $typemeta[$type]['enum'] ) == 0 ) { + //comment + print $indent ."\t/**\n". $indent ."\t * Gets the value of this element.\n"; + print $indent ."\t * @return Returns a ". $pre . ucfirst( $type ) ." of the value.\n"; + print $indent ."\t */\n"; + //code + print $indent ."\t".$pre . ucfirst( $type ) ." getValue() const { return _value; }\n"; + //comment + print $indent ."\t/**\n". $indent ."\t * Sets the _value of this element.\n"; + print $indent ."\t * @param val The new value for this element.\n"; + print $indent ."\t */\n"; + //code + print $indent ."\tvoid setValue( ". $pre . ucfirst( $type ) ." val ) { *(daeStringRef*)&_value = val; }\n\n"; + } + else { + //comment + print $indent ."\t/**\n". $indent ."\t * Gets the value of this element.\n"; + print $indent ."\t * @return a ". $pre . ucfirst( $type ) ." of the value.\n"; + print $indent ."\t */\n"; + //code + print $indent ."\t".$pre . ucfirst( $type ) ."& getValue() { return _value; }\n"; + //comment + print $indent ."\t/**\n". $indent ."\t * Sets the _value of this element.\n"; + print $indent ."\t * @param val The new value for this element.\n"; + print $indent ."\t */\n"; + //code + print $indent ."\tvoid setValue( const ". $pre . ucfirst( $type ) ."& val ) { _value = val; }\n\n"; + //print $indent ."\t _meta->getValueAttribute()->setIsValid(true); }\n\n"; + } + } + } + } +} + +?> diff --git a/1.4.0/dom/codeGen/1.5/tpl/tpl-class-def.php b/1.4.0/dom/codeGen/1.5/tpl/tpl-class-def.php new file mode 100644 index 0000000..7447c21 --- /dev/null +++ b/1.4.0/dom/codeGen/1.5/tpl/tpl-class-def.php @@ -0,0 +1,205 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +global $meta; +global $typemeta; +$needsContents = false; + + +// XXX all occurences of 'baseTypeViaRestriction' are ugly hacks to get +// a working dom for 1.5 +if(isset($bag['baseTypeViaRestriction'])) { + print '#include <dom/' . + $_globals['prefix'] . ucfirst( $bag['baseTypeViaRestriction'] ) . + '.h>'."\n"; +} + + +// shorthand: +$full_element_name = $_globals['prefix'] . ucfirst( $bag['element_name'] ); +//COLLADA TYPE list +if ( array_search( $bag['element_name'], $_globals['elementTypes'] ) === FALSE ) +{ + $_globals['elementTypes'][] = $bag['element_name']; +} +//COLLADA ELEMENT list +for( $i=0; $i<count( $bag['elements'] ); $i++ ) +{ + if ( array_search( $bag['elements'][$i], $_globals['elementNames'] ) === FALSE ) + { + $_globals['elementNames'][] = $bag['elements'][$i]; + } +} +if ( $bag['substitution_group'] != '' ) +{ + //also add this element to the list of elements. + if ( array_search( $bag['element_name'], $_globals['elementNames'] ) === FALSE ) + { + $_globals['elementNames'][] = $bag['element_name']; + } +} + +$indent = ""; +for ($i = 0; $i < $GLOBALS['indentNum']; $i++ ) { + $indent .= "\t"; +} +if ( $GLOBALS['indentNum'] > 0 ) { //only print these for the inner classes.. the main classes will have + //them defined in a seperate file to avoid circular includes. + print $indent."class " . $full_element_name . ";\n\n"; + print $indent ."typedef daeSmartRef<". $full_element_name ."> ". $full_element_name ."Ref;\n"; + print $indent ."typedef daeTArray<". $full_element_name ."Ref> ". $full_element_name ."_Array;\n\n"; +} + +// DOCUMENTATION +if ( isset( $bag['documentation'][ $_globals['language'] ] ) ) +{ + print applyTemplate( 'DOXYGEN', $bag['documentation'][ $_globals['language'] ] ); +} + +// SUBSTITION GROUP/INHERITANCE +$baseClass = 'daeElement'; +if($bag['substitution_group'] != '') + $baseClass = $_globals['prefix'] . ucfirst($bag['substitution_group']); +if($bag['isExtension']) + $baseClass = $_globals['prefix'] . ucfirst($bag['base_type']); +if(isset($bag['baseTypeViaRestriction'])) + $baseClass = $_globals['prefix'] . ucfirst($bag['baseTypeViaRestriction']); + +print $indent ."class ". $full_element_name . " : public " . $baseClass . "\n".$indent."{\n"; +print $indent ."public:\n"; +print $indent ."\tvirtual COLLADA_TYPE::TypeEnum getElementType() const { return COLLADA_TYPE::". strtoupper($bag['element_name']) ."; }\n"; +print $indent ."\tstatic daeInt ID() { return ". $_globals['typeID']++ ."; }\n"; +print $indent ."\tvirtual daeInt typeID() const { return ID(); }\n"; + +// INTERNAL CLASSES +$result = ''; +$inlines = array_keys( $bag['inline_elements'] ); +for( $i=0; $i<count( $inlines ); $i++ ) +{ + $inner = $bag['inline_elements'][ $inlines[$i] ]; + if ( !$inner['complex_type'] || $inner['isRestriction'] || $inner['isExtension'] ) { + $GLOBALS['indentNum']++; + $result .= applyTemplate( 'CLASS', $inner ); + $GLOBALS['indentNum']--; + } +} +if ( strlen( $result ) > 0 ) { print $indent ."public:\n$result\n"; } + +//ENUM +if ( $bag['simple_type'] != NULL ) { + $typeMeta = $bag['simple_type']->getMeta(); + //print $typeMeta['type']; + if ( count( $typeMeta['enum'] ) > 0 ) + { + //print "has enums"; + print $indent ."public: //ENUM\n"; + if ( !$typeMeta['useConstStrings'] ) { + //Decided to name mangle the enum constants so they are more descriptive and avoid collisions + if ( isset( $typeMeta['documentation']['en'] ) ) { + print applyTemplate( 'DOXYGEN', $typeMeta['documentation']['en'] ); + } + print "enum " . $_globals['prefix'] . ucfirst( $typeMeta['type'] ) . "_type {\n"; + //print "\t" . strtoupper( $typeMeta['type'] ) . "_" . $typeMeta['enum'][0] ." = 1"; + for( $i = 0; $i < count( $typeMeta['enum'] ); $i++ ) { + //print ","; + print "\t" . strtoupper( $typeMeta['type'] ) . "_" . $typeMeta['enum'][$i] .","; + if ( isset( $typeMeta['enum_documentation'][$i] ) ) { + print "\t\t/**< ". $typeMeta['enum_documentation'][$i] ." */"; + } + //print "\n\t" . strtoupper( $typeMeta['type'] ) . "_" . $typeMeta['enum'][$i]; + print "\n"; + } + //if ( isset( $typeMeta['enum_documentation'][count( $typeMeta['enum'] )-1] ) ) { + // print "\t\t/**< ". $typeMeta['enum_documentation'][count( $typeMeta['enum'] )-1] ." */"; + //} + print "\t". strtoupper( $typeMeta['type'] ) . "_COUNT"; + print "\n};\n\n"; + } + else { + //if ( isset( $typeMeta['documentation']['en'] ) ) { + // $_globals['constStrings'][] = applyTemplate( 'DOXYGEN', $typeMeta['documentation']['en'] ); + //} + for( $i = 0; $i < count( $typeMeta['enum'] ); $i++ ) { + //print "static const daeString ". strtoupper( $typeMeta['type'] ) . "_" . $typeMeta['enum'][$i]; + //print " = \"". $typeMeta['enum'][$i] ."\";\n"; + if ( isset( $typeMeta['enum_documentation'][$i] ) ) { + $_globals['constStrings'][] = "/**\n * ". $typeMeta['enum_documentation'][$i] ."\n */\n"; + } + $conststrnm = strtoupper( $typeMeta['type'] ) . "_" . $typeMeta['enum'][$i]; + $conststr = "\"". $typeMeta['enum'][$i] ."\";\n"; + $_globals['constStrings'][$conststrnm] = $conststr; + } + $_globals['constStrings'][] = "\n"; + } + } +} + +// ATTRIBUTES +if ( ( count( $bag['attributes'] ) > 0 || $bag['useXMLNS'] ) /*&& !isset($bag['baseTypeViaRestriction'])*/ ) +{ + print $indent ."protected: // Attribute". (count( $bag['attributes'] ) > 1 ? 's' : '') ."\n"; + + if ( $bag['useXMLNS'] ) { + print $indent ."\t/**\n". $indent ."\t * This element may specify its own xmlns.\n". $indent ."\t */\n"; + print $indent ."\txsAnyURI attrXmlns;\n"; + } + foreach( $bag['attributes'] as $attr_name => & $a_list ) + { + $type = $a_list['type']; + $pre = ''; + getTypeNameAndPrefix($type, $pre); + if ( $type == '' ) + { + $type = "String"; + } + if ( isset( $a_list['documentation'] ) ) { + print applyTemplate( 'DOXYGEN', $a_list['documentation'] ); + } + print $indent ."\t" . $pre . ucfirst( $type ) . " attr" . ucfirst($attr_name) .";\n"; + } +} + +// ELEMENTS +if ( count( $bag['attributes'] > 0 ) ) { print "\n"; } +printElements($bag, $needsContents, $indent); + +printAccessorsAndMutators($bag, $needsContents, $indent); + +//VALUE +// NOTE: special casing any element with 'mixed' content model to ListOfInts type _value +if ( ( ($bag['content_type'] != '' || $bag['mixed']) && !$bag['abstract'] ) && !isset($bag['baseTypeViaRestriction']) ) +{ + print $indent ."protected: // Value\n"; + + $content_type = $bag['content_type']; + $pre = ''; + getTypeNameAndPrefix($content_type, $pre); + if ( $bag['parent_meta']['inline_elements'] != NULL && array_key_exists( $content_type, $bag['parent_meta']['inline_elements'] ) ) { + $pre = '::' . $pre; + } + print $indent ."\t/**\n". $indent ."\t * The " . $pre . ucfirst( $content_type ) ." value of the text data of this element. "; + print "\n". $indent ."\t */\n"; + $valueType = $pre . ucfirst($content_type); + if($meta[$content_type]['isAComplexType']) + $valueType = $valueType . "Ref"; + print $indent ."\t". $valueType ." _value;\n"; +} + +//CONSTRUCTORS +printConstructors( $full_element_name, $bag, $baseClass, $indent ); + +print "\n".$indent ."public: // STATIC METHODS\n"; +print $indent ."\t/**\n". $indent ."\t * Creates an instance of this class and returns a daeElementRef referencing it.\n"; +print $indent ."\t * @return a daeElementRef referencing an instance of this object.\n". $indent ."\t */\n"; +print $indent ."\tstatic DLLSPEC ". $_globals['meta_prefix'] ."ElementRef create(DAE& dae);\n"; +print $indent ."\t/**\n". $indent ."\t * Creates a daeMetaElement object that describes this element in the meta object reflection framework."; +print "\n". $indent ."\t * If a daeMetaElement already exists it will return that instead of creating a new one. \n"; +print $indent ."\t * @return A daeMetaElement describing this COLLADA element.\n". $indent ."\t */\n"; +print $indent ."\tstatic DLLSPEC ". $_globals['meta_prefix'] ."MetaElement* registerElement(DAE& dae);\n"; +print $indent ."};\n\n"; diff --git a/1.4.0/dom/codeGen/1.5/tpl/tpl-constants-cpp-file.php b/1.4.0/dom/codeGen/1.5/tpl/tpl-constants-cpp-file.php new file mode 100644 index 0000000..c6141e2 --- /dev/null +++ b/1.4.0/dom/codeGen/1.5/tpl/tpl-constants-cpp-file.php @@ -0,0 +1,16 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +// Grab the file name and save the output +$_file = $_globals['prefix'] . "Constants.cpp"; +$_bytes = file_put_contents( ($_globals['target_dir'] . $_globals['dom_dir'] . 'src/' . $_file), applyTemplate( 'CONSTANTS_CPP', $bag ) ); + +//if ( $_bytes > 0 ) { print "Wrote $_bytes bytes to file '$_file'\n"; } + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.5/tpl/tpl-constants-cpp.php b/1.4.0/dom/codeGen/1.5/tpl/tpl-constants-cpp.php new file mode 100644 index 0000000..30d113d --- /dev/null +++ b/1.4.0/dom/codeGen/1.5/tpl/tpl-constants-cpp.php @@ -0,0 +1,36 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +if ( $_globals['copyright'] ) { +print $_globals['copyright_text']; +} +?> +#include <dom/domConstants.h> + +<?php + foreach ($bag as $name => $val ) { + if ( is_int($name) ) { + print $val; + continue; + } + print "DLLSPEC daeString ". $name ." = ". $val; + } + print "\n"; + + foreach ($_globals['elementTypes'] as $num => $val ) + { + print "DLLSPEC daeString COLLADA_TYPE_". getUniqueName($val, $_globals['elementTypes']) ." = \"". $val ."\";\n"; + } + print "\n"; + + foreach ($_globals['elementNames'] as $num => $val ) + { + print "DLLSPEC daeString COLLADA_ELEMENT_". getUniqueName($val, $_globals['elementNames']) ." = \"". $val ."\";\n"; + } +?> diff --git a/1.4.0/dom/codeGen/1.5/tpl/tpl-constants-file.php b/1.4.0/dom/codeGen/1.5/tpl/tpl-constants-file.php new file mode 100644 index 0000000..8bfc456 --- /dev/null +++ b/1.4.0/dom/codeGen/1.5/tpl/tpl-constants-file.php @@ -0,0 +1,16 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +// Grab the file name and save the output +$_file = $_globals['prefix'] . "Constants.h"; +$_bytes = file_put_contents( ($_globals['target_dir'] . $_globals['dom_dir']. 'include/' . $_file), applyTemplate( 'CONSTANTS', $bag ) ); + +//if ( $_bytes > 0 ) { print "Wrote $_bytes bytes to file '$_file'\n"; } + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.5/tpl/tpl-constants.php b/1.4.0/dom/codeGen/1.5/tpl/tpl-constants.php new file mode 100644 index 0000000..199e849 --- /dev/null +++ b/1.4.0/dom/codeGen/1.5/tpl/tpl-constants.php @@ -0,0 +1,42 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +if ( $_globals['copyright'] ) { +print $_globals['copyright_text']; +} +?> +#ifndef __DOM_CONSTANTS_H__ +#define __DOM_CONSTANTS_H__ + +#include <dae/daeDomTypes.h> + +<?php + foreach ($bag as $name => $val ) { + if ( is_int($name) ) { + print $val; + continue; + } + print "extern DLLSPEC daeString ". $name .";\n"; + } + print "\n"; + + foreach ($_globals['elementTypes'] as $num => $val ) + { + print "extern DLLSPEC daeString COLLADA_TYPE_". getUniqueName($val, $_globals['elementTypes']) .";\n"; + } + print "\n"; + + foreach ($_globals['elementNames'] as $num => $val ) + { + print "extern DLLSPEC daeString COLLADA_ELEMENT_". getUniqueName($val, $_globals['elementNames']) .";\n"; + } +?> + +#endif //__DOM_CONSTANTS_H__ + diff --git a/1.4.0/dom/codeGen/1.5/tpl/tpl-cpp-body.php b/1.4.0/dom/codeGen/1.5/tpl/tpl-cpp-body.php new file mode 100644 index 0000000..757e953 --- /dev/null +++ b/1.4.0/dom/codeGen/1.5/tpl/tpl-cpp-body.php @@ -0,0 +1,25 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +if ( $_globals['copyright'] ) { +print $_globals['copyright_text']; +} +?> +#include <dae.h> +#include <<?= $_globals['meta_prefix'] ?>/daeDom.h> +#include <<?= $_globals['prefix'] ?>/<?= $_globals['prefix'] . ucfirst( $bag['element_name'] ) . ".h" ?>> +#include <<?= $_globals['meta_prefix'] ?>/daeMetaCMPolicy.h> +#include <<?= $_globals['meta_prefix'] ?>/daeMetaSequence.h> +#include <<?= $_globals['meta_prefix'] ?>/daeMetaChoice.h> +#include <<?= $_globals['meta_prefix'] ?>/daeMetaGroup.h> +#include <<?= $_globals['meta_prefix'] ?>/daeMetaAny.h> +#include <<?= $_globals['meta_prefix'] ?>/daeMetaElementAttribute.h> + +<?= applyTemplate( 'CPP_METHODS', $bag ) ?> +<?= applyTemplate( 'CPP_STATIC', $bag ) ?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.5/tpl/tpl-cpp-methods.php b/1.4.0/dom/codeGen/1.5/tpl/tpl-cpp-methods.php new file mode 100644 index 0000000..93e90a5 --- /dev/null +++ b/1.4.0/dom/codeGen/1.5/tpl/tpl-cpp-methods.php @@ -0,0 +1,484 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + + global $meta; + global $typemeta; + + $_context = $bag['context']; + for( $i=0; $i<count( $_context ); $i++ ) + { + $_context[$i] = $_globals['prefix'] . ucfirst( $_context[$i] ); + } + $scoped_element = implode( '::', $_context ); + + /*if ( $bag['has_any'] ) { + foreach ( $meta as $nm => $lm ) { + if ( !$lm['isAGroup'] && !$lm['isAComplexType'] && !$lm['abstract'] ) { + print "#include <". $_globals['prefix'] ."/". $_globals['prefix'] . ucfirst($nm).".h>\n"; + } + } + print "\n"; + }*/ + + if ( $scoped_element == "domCOLLADA" ) { + print "extern daeString COLLADA_VERSION;\n"; + print "extern daeString COLLADA_NAMESPACE;\n\n"; + } +?><?= $_globals['meta_prefix'] ?>ElementRef +<?= $scoped_element ?>::create(DAE& dae) +{ + <?= $scoped_element ?>Ref ref = new <?= $scoped_element ?>(dae); +<?php + if ( $bag['useXMLNS'] ) { + print "\tref->attrXmlns.setContainer( (". $scoped_element ."*)ref );\n"; + } + foreach( $bag['attributes'] as $attr_name => & $a_list ) { + if ( $a_list['type'] == 'xs:anyURI' || $a_list['type'] == 'urifragment' ) { + print "\tref->attr". ucfirst($attr_name) .".setContainer( (". $scoped_element ."*)ref );\n"; + } + } + if ( $bag['content_type'] == 'xs:anyURI' || $bag['content_type'] == 'urifragment' ) { + print "\tref->_value.setContainer( (". $scoped_element ."*)ref );\n"; + } + if ( $scoped_element == "domCOLLADA" ) { + print "\tref->_meta = dae.getMeta(domCOLLADA::ID());\n"; + print "\tref->setAttribute(\"version\", COLLADA_VERSION );\n"; + print "\tref->setAttribute(\"xmlns\", COLLADA_NAMESPACE );\n"; + print "\tref->_meta = NULL;\n"; + } +?> + return ref; +} + +<?php + if( ( $bag['complex_type'] && !$bag['isRestriction'] ) || isset($bag['baseTypeViaRestriction']) ) { + //print "element ". $bag['element_name'] ." is of base ". $bag['base_type'] ."\n"; + //import content model from type + $bag['elements'] = array_merge( $meta[$bag['base_type']]['elements'], $bag['elements'] ); + $bag['element_attrs'] = array_merge( $meta[$bag['base_type']]['element_attrs'], $bag['element_attrs'] ); + $bag['content_type'] = $meta[$bag['base_type']]['content_type']; + $bag['attributes'] = array_merge( $meta[$bag['base_type']]['attributes'], $bag['attributes'] ); + $tempArray = array(); + if ( count( $bag['content_model'] ) > 0 ) { + //we have an addition to the content model - need to add a starting sequence + $tempArray[] = array( 'name' => 0, 'minOccurs' => 1, 'maxOccurs' => 1 ); + } + $tempArray = array_merge( $tempArray, $meta[$bag['base_type']]['content_model'] ); + array_pop( $tempArray ); //remove the last END token + $tempArray = array_merge( $tempArray, $bag['content_model'] ); + if ( count( $bag['content_model'] ) > 0 ) { + //we have an addition to the content model - need to add a starting sequence + $tempArray[] = array( 'name' => 5, 'minOccurs' => 1, 'maxOccurs' => 1 ); + } + $bag['content_model'] = $tempArray; + } + + for( $i=0; $i<count( $bag['elements'] ); $i++ ) { + if ( isset( $meta[$bag['elements'][$i]] ) ) { + $cnt = count( $meta[$bag['elements'][$i]]['substitutableWith']); + for ( $c = 0; $c < $cnt; $c++ ) { + $subwith = $meta[$bag['elements'][$i]]['substitutableWith'][$c]; + print $prefix ."#include <". $_globals['prefix'] ."/". $_globals['prefix'] . ucfirst( $subwith ) .".h>\n"; + } + } + } +?> + +<?= $_globals['meta_prefix'] ?>MetaElement * +<?= $scoped_element ?>::registerElement(DAE& dae) +{ + <?= $_globals['meta_prefix'] ?>MetaElement* meta = dae.getMeta(ID()); + if ( meta != NULL ) return meta; + + meta = new daeMetaElement(dae); + dae.setMeta(ID(), *meta); + meta->setName( "<?= $bag['element_name'] ?>" ); + meta->registerClass(<?= $scoped_element ?>::create); + +<?php + if ( $bag['isAGroup'] ) { + print "\tmeta->setIsTransparent( true );\n"; + } + if ( $bag['abstract'] ) { + print "\tmeta->setIsAbstract( true );\n"; + } + if ( isset( $bag['parent_meta'] ) ) { + print "\tmeta->setIsInnerClass( true );\n"; + } + + if ( count( $bag['elements'] ) > 0 || $bag['has_any'] ) + { + print "\tdaeMetaCMPolicy *cm = NULL;\n"; + if ( !$bag['has_any'] ) { + print "\tdaeMetaElementAttribute *mea = NULL;\n"; + } + + $needsContents = false; + $cmTree = array(); + $currentCM = NULL; + $currentOrd = 0; + $level = 0; + $choiceNum = 0; + + // !!!steveT Hack alert. In the 1.5 schema there's a single element named + // 'sampler_states_type' that contains a group ref that isn't contained in + // an xs:sequence or xs:choice the way all the other group refs are. The + // code generator handles this case incorrectly. It outputs code that causes + // the DOM to crash when you try to create a DAE object. + // + // Unfortunately I don't know what the proper solution is, so this hack just + // detects that specific group ref type and treats it like it's in an + // xs:sequence. I have no idea if that's right, but it causes the DOM not to + // crash anyway. + $containsGroup = false; + $containsOther = false; + for( $i=0; $i<count( $bag['content_model'] ) - 1; $i++ ) { + $cm = $bag['content_model'][$i]; + if(is_int($cm['name']) && $cm['name'] == 2) + $containsGroup = true; + if(is_int($cm['name']) && $cm['name'] != 2) + $containsOther = true; + } + $hack = $containsGroup && !$containsOther; + + for( $i=0; $i<count( $bag['content_model'] ) - 1; $i++ ) + { + $cm = $bag['content_model'][$i]; + if ( $cm['maxOccurs'] == "unbounded" ) + { + $cm['maxOccurs'] = -1; + } + if ( is_int( $cm['name'] ) ) + { + if ( $cm['name'] == 0 || ($i == 0 && $hack)) //sequence + { + //if ( $level > 0 ) { + // $needsContents = true; + //} + + // !!!steveT Horrible hack here. For some reason the wrong value gets generated for + // the third parameter + if (strcmp($scoped_element, "domCamera::domOptics::domTechnique_common::domPerspective") == 0) + print "\tcm = new daeMetaSequence( meta, cm, 0, ". $cm['minOccurs'] .", ". $cm['maxOccurs'] ." );\n\n"; + else + print "\tcm = new daeMetaSequence( meta, cm, ". $currentOrd .", ". $cm['minOccurs'] .", ". $cm['maxOccurs'] ." );\n\n"; + + $level++; + $currentCM = array( 'cm' => $currentCM['cm'], 'ord' => $currentOrd ); + array_push( $cmTree, $currentCM ); + $currentCM = array( 'cm' => $cm, 'ord' => $currentOrd ); + $currentOrd = 0; + } + else if ( $cm['name'] == 1 ) //choice + { + print "\tcm = new daeMetaChoice( meta, cm, ". $choiceNum .", ". $currentOrd .", ". $cm['minOccurs'] .", ". $cm['maxOccurs'] ." );\n\n"; + $level++; + $needsContents = true; + $currentCM = array( 'cm' => $currentCM['cm'], 'ord' => $currentOrd ); + array_push( $cmTree, $currentCM ); + $currentCM = array( 'cm' => $cm, 'ord' => $currentOrd ); + $currentOrd = 0; + $choiceNum++; + } + else if ( $cm['name'] == 2 ) //group + { + $i++; //groups actually add two parts to the content model. The first is the group the second an element + $groupName = $bag['content_model'][$i]['name']; + $arrayOrNot = $bag['element_attrs'][ $groupName ]['maxOccurs']; + if ( $arrayOrNot == 'unbounded' || $arrayOrNot > 1 ) { + $arrayOrNot = true; + } + else { + $arrayOrNot = false; + } +?> + mea = new daeMetaElement<?= $arrayOrNot ? 'Array' : '' ?>Attribute( meta, cm, <?= $currentOrd ?>, <?= $cm['minOccurs'] ?>, <?= $cm['maxOccurs'] ?> ); + mea->setName( "<?= $groupName ?>" ); + mea->setOffset( daeOffsetOf(<?= $scoped_element ?>,elem<?= ucfirst( $groupName ) ?><?= $arrayOrNot ? '_array' : '' ?>) ); + mea->setElementType( <?= $_globals['prefix'] . ucfirst( $groupName ) ?>::registerElement(dae) ); + cm->appendChild( new daeMetaGroup( mea, meta, cm, <?= $currentOrd ?>, <?= $cm['minOccurs'] ?>, <?= $cm['maxOccurs'] ?> ) ); + +<?php + if ( $currentCM['cm']['name'] == 0 ) { + $currentOrd++; + } + } + else if ( $cm['name'] == 3 ) //all + { + //print "\tcm = new daeMetaAll( meta, cm, ". $cm['minOccurs'] .", ". $cm['maxOccurs'] ." );\n"; + $level++; + $needsContents = true; + $currentCM = array( 'cm' => $currentCM['cm'], 'ord' => $currentOrd ); + array_push( $cmTree, $currentCM ); + $currentCM = array( 'cm' => $cm, 'ord' => $currentOrd ); + $currentOrd = 0; + } + else if ( $cm['name'] == 4 ) //any + { + $level++; + print "\tcm = new daeMetaAny( meta, cm, ". $currentOrd .", ". $cm['minOccurs'] .", ". $cm['maxOccurs'] ." );\n\n"; + if ( $currentCM['cm']['name'] == 0 ) { + $currentOrd++; + } + } + else if ( $cm['name'] == 5 ) //end + { + $level--; + if ( $level > 0 ) + { +?> + cm->setMaxOrdinal( <?= ($currentOrd-1 >= 0)? $currentOrd-1 : 0 ?> ); + cm->getParent()->appendChild( cm ); + cm = cm->getParent(); + +<?php + } + //---------------------- + if ( $currentCM['cm']['name'] == 0 ) { + $tempMaxO = $currentCM['cm']['maxOccurs']; + $currentCM = array_pop( $cmTree ); + if ( $tempMaxO == -1 ) { + $currentOrd = $currentCM['ord'] + 3000; + } + else { + $currentOrd = $currentCM['ord'] + $tempMaxO*$currentOrd; + } + } + else { + $tempMaxO = $currentCM['cm']['maxOccurs']; + if ( $tempMaxO == -1 ) $tempMaxO = 3001; + $currentCM = array_pop( $cmTree ); + $currentOrd = $currentCM['ord'] + $tempMaxO; + } + } + } + else //got an element name + { + $arrayOrNot = $bag['element_attrs'][ $cm['name'] ]['maxOccurs']; + if ( $arrayOrNot == 'unbounded' || $arrayOrNot > 1 ) { + $arrayOrNot = true; + } + else { + $arrayOrNot = false; + } + $typeClass = $_globals['prefix'] . ucfirst( $cm['name'] ); + + if ( !in_array( $cm['name'], $bag['ref_elements'] ) && !$bag['complex_type'] ) { + $typeClass = $scoped_element ."::". $typeClass; + } + if ( isset( $bag['element_attrs'][ $cm['name'] ]['type'] ) && + isset( $meta[$bag['element_attrs'][ $cm['name'] ]['type']] ) ){ + + $typeClass = $_globals['prefix'] . ucfirst( $bag['element_attrs'][ $cm['name'] ]['type'] ); + } +?> + mea = new daeMetaElement<?= $arrayOrNot ? 'Array' : '' ?>Attribute( meta, cm, <?= $currentOrd ?>, <?= $cm['minOccurs'] ?>, <?= $cm['maxOccurs'] ?> ); + mea->setName( "<?= $cm['name'] ?>" ); + mea->setOffset( daeOffsetOf(<?= $scoped_element ?>,elem<?= ucfirst( $cm['name'] ) ?><?= $arrayOrNot ? '_array' : '' ?>) ); + mea->setElementType( <?= $typeClass ?>::registerElement(dae) ); + cm->appendChild( mea ); + +<?php + if ( isset( $meta[$cm['name']] ) ) { + $cnt = count( $meta[$cm['name']]['substitutableWith']); + for ( $c = 0; $c < $cnt; $c++ ) { + $subwith = $meta[$cm['name']]['substitutableWith'][$c]; +?> + mea = new daeMetaElement<?= $arrayOrNot ? 'Array' : '' ?>Attribute( meta, cm, <?= $currentOrd ?>, <?= $cm['minOccurs'] ?>, <?= $cm['maxOccurs'] ?> ); + mea->setName( "<?= $subwith ?>" ); + mea->setOffset( daeOffsetOf(<?= $scoped_element ?>,elem<?= ucfirst( $cm['name'] ) ?><?= $arrayOrNot ? '_array' : '' ?>) ); + mea->setElementType( <?= $_globals['prefix'] . ucfirst( $subwith ) ?>::registerElement(dae) ); + cm->appendChild( mea ); + +<?php + $needsContents = true; + } + } + if ( $currentCM['cm']['name'] == 0 ) { + $currentOrd++; + } + } + } +?> + cm->setMaxOrdinal( <?= ($currentOrd-1 >= 0)? $currentOrd-1 : 0 ?> ); + meta->setCMRoot( cm ); +<?php + + if ( $bag['has_any'] ) { + $needsContents = true; + print "\tmeta->setAllowsAny( true );\n"; + } + + // For elements that allow more than one type of sub-element, _contents keeps an order for those sub-elements + if ( $bag['hasChoice'] || $needsContents ) { +?> + // Ordered list of sub-elements + meta->addContents(daeOffsetOf(<?= $scoped_element ?>,_contents)); + meta->addContentsOrder(daeOffsetOf(<?= $scoped_element ?>,_contentsOrder)); + +<?php + if ( $choiceNum > 0 ) + { +?> + meta->addCMDataArray(daeOffsetOf(<?= $scoped_element ?>,_CMData), <?= $choiceNum ?>);<?php + } + } + } + + // TAKE CARE OF THE ENUM IF IT HAS ONE!! + if ( $bag['simple_type'] != NULL ) { + $typeMeta = $bag['simple_type']->getMeta(); + + if ( count( $typeMeta['enum'] ) > 0 && !$typeMeta['useConstStrings'] ) + { +?> + // ENUM: <?= ucfirst( $typeMeta['type'] ) ?>_type + daeAtomicType *type; + type = new daeEnumType; + type->_nameBindings.append("<?= ucfirst( $typeMeta['type'] ) ?>_type"); + ((daeEnumType*)type)->_strings = new daeStringRefArray; + ((daeEnumType*)type)->_values = new daeEnumArray; +<?php + foreach( $typeMeta['enum'] as $val ) + { +?> + ((daeEnumType*)type)->_strings->append("<?= $val ?>"); + ((daeEnumType*)type)->_values->append(<?= strtoupper($typeMeta['type']) . "_" . $val ?>); +<?php + } + print "\tdaeAtomicType::append( type );\n\n"; + } + } + + // NOTE: special casing any element with 'mixed' content model to ListOfInts type _value + $pre = ''; + if (($bag['content_type'] != '' || $bag['mixed']) && !$bag['abstract'] ) { +?> + // Add attribute: _value + { +<?php + $content_type = ( $bag['mixed'] ? 'ListOfInts' : $bag['content_type'] ); + if ( preg_match( "/xs\:/", $content_type ) ) { + $content_type = substr( $content_type, 3 ); + $pre = 'xs'; + } + //print "\t\tdaeMetaAttribute* ma = daeMetaAttribute::makeAttrForType(\"". ucfirst($content_type) ."\");\n"; + if ( (isset( $typemeta[$content_type] ) && $typemeta[$content_type]['isArray']) || $content_type == 'IDREFS' ) { + print "\t\tdaeMetaAttribute *ma = new daeMetaArrayAttribute;\n"; + } + else { + print "\t\tdaeMetaAttribute *ma = new daeMetaAttribute;\n"; + } +?> + ma->setName( "_value" ); +<?php + //if ( $bag['mixed'] ) { + // print "#ifdef POLYGONS_MIXED_CONTENT_MODEL_HOLES\n\t\tma->setType( daeAtomicType::get(\"ListOfStrings\"));\n"; + // print "#else\n\t\tma->setType( daeAtomicType::get(\"ListOfInts\"));\n#endif\n"; + //} + //else { + print "\t\tma->setType( dae.getAtomicTypes().get(\"". $pre. ucfirst($content_type) ."\"));\n"; + //} +?> + ma->setOffset( daeOffsetOf( <?= $scoped_element ?> , _value )); + ma->setContainer( meta ); + meta->appendAttribute(ma); + } +<?php + } + + if ( $bag['useXMLNS'] ) { + ?> + // Add attribute: xmlns + { + daeMetaAttribute* ma = new daeMetaAttribute; + ma->setName( "xmlns" ); + ma->setType( dae.getAtomicTypes().get("xsAnyURI")); + ma->setOffset( daeOffsetOf( <?= $scoped_element ?> , attrXmlns )); + ma->setContainer( meta ); + //ma->setIsRequired( true ); + meta->appendAttribute(ma); + } + <?php + } + + foreach( $bag['attributes'] as $attr_name => $attr_attrs ) + { + $_type = $attr_attrs['type']; + $printType; + if ( preg_match( "/xs\:/", $_type ) ) { + $_type = 'xs' . ucfirst( substr( $_type, 3 ) ); + $printType = $_type; + } + else { + $printType = ucfirst( $_type ); + } +?> + + // Add attribute: <?= $attr_name . "\n" ?> + { +<?php + /*print "\t//". $_type ." is set "; + if ( isset( $typemeta[$_type] ) ) print "true\n"; + else print "false\n"; + + print "\t//is array "; + if ( $typemeta[$_type]['isArray'] ) print "true\n"; + else print "false\n";*/ + + if ( isset( $typemeta[$_type] ) && $typemeta[$_type]['isArray'] ) { + print "\t\tdaeMetaAttribute *ma = new daeMetaArrayAttribute;\n"; + } + else { + print "\t\tdaeMetaAttribute *ma = new daeMetaAttribute;\n"; + } +?> + ma->setName( "<?= $attr_name ?>" ); + ma->setType( dae.getAtomicTypes().get("<?= $printType ?>")); + ma->setOffset( daeOffsetOf( <?= $scoped_element ?> , attr<?= ucfirst($attr_name) ?> )); + ma->setContainer( meta ); +<?php + if ( isset( $attr_attrs['default'] ) ) + { +?> ma->setDefaultString( "<?= $attr_attrs['default'] ?>"); +<?php + } + + if ( isset( $attr_attrs['use'] ) ) { + $required = $attr_attrs['use'] == 'required' ? 'true' : 'false'; + +?> ma->setIsRequired( <?= $required ?> ); +<?php + } +?> + meta->appendAttribute(ma); + } +<?php + } +?> + + meta->setElementSize(sizeof(<?= $scoped_element ?>)); + meta->validate(); + + return meta; +} + +<?php + $_keys = array_keys( $bag['inline_elements'] ); + if ( count( $_keys ) > 0 ) + { + foreach( $_keys as $_k ) + { + $inner = $bag['inline_elements'][ $_k ]; + if ( !$inner['complex_type'] || $inner['isRestriction'] || $inner['isExtension'] ) { + print applyTemplate( 'CPP_METHODS', $inner ); + } + } + } +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.5/tpl/tpl-cpp-static.php b/1.4.0/dom/codeGen/1.5/tpl/tpl-cpp-static.php new file mode 100644 index 0000000..80508b1 --- /dev/null +++ b/1.4.0/dom/codeGen/1.5/tpl/tpl-cpp-static.php @@ -0,0 +1,29 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + + $_context = $bag['context']; + for( $i=0; $i<count( $_context ); $i++ ) + { + $_context[$i] = $_globals['prefix'] . ucfirst( $_context[$i] );//. "_element"; + } +?> +<?php +//} + $keys = array_keys( $bag['inline_elements'] ); + if ( count( $keys ) > 0 ) + { + foreach( $keys as $k ) + { + $inner = $bag['inline_elements'][ $k ]; + if ( !$inner['complex_type'] || $inner['isRestriction'] || $inner['isExtension'] ) { + print applyTemplate( 'CPP_STATIC', $inner ); + } + } + } +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.5/tpl/tpl-cpp.php b/1.4.0/dom/codeGen/1.5/tpl/tpl-cpp.php new file mode 100644 index 0000000..49c3b42 --- /dev/null +++ b/1.4.0/dom/codeGen/1.5/tpl/tpl-cpp.php @@ -0,0 +1,16 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +// Grab the file name and save the output +$_file = $_globals['prefix'] . ucfirst( $bag['element_name'] ) . ".cpp"; +$_bytes = file_put_contents( ($_globals['target_dir'] . $_globals['dom_dir'] . 'src/' . $_file), applyTemplate( 'CPP', $bag ) ); + +//if ( $_bytes > 0 ) { print "Wrote $_bytes bytes to file '$_file'\n"; } + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.5/tpl/tpl-dot-h.php b/1.4.0/dom/codeGen/1.5/tpl/tpl-dot-h.php new file mode 100644 index 0000000..6d14e57 --- /dev/null +++ b/1.4.0/dom/codeGen/1.5/tpl/tpl-dot-h.php @@ -0,0 +1,28 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +if ( $_globals['copyright'] ) { +print $_globals['copyright_text']; +} +?>#ifndef __<?= $_globals['prefix'] . ucfirst( $bag['element_name'] ) ?>_h__ +#define __<?= $_globals['prefix'] . ucfirst( $bag['element_name'] ) ?>_h__ + +#include <dae/daeDocument.h> +#include <<?= $_globals['prefix'] . '/' . $_globals['prefix'] ?>Types.h> +#include <<?= $_globals['prefix'] . '/' . $_globals['prefix'] ?>Elements.h> + +<?php +global $includeList; +$includeList = array(); +print applyTemplate( 'INCLUDES', $bag ) ?> +class DAE; + +<?= applyTemplate( 'CLASS', $bag ) ?> + +#endif diff --git a/1.4.0/dom/codeGen/1.5/tpl/tpl-doxygen.php b/1.4.0/dom/codeGen/1.5/tpl/tpl-doxygen.php new file mode 100644 index 0000000..30a6d6d --- /dev/null +++ b/1.4.0/dom/codeGen/1.5/tpl/tpl-doxygen.php @@ -0,0 +1,38 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +global $indent; +// Add doxygen formatted comments + +print $indent ."/**\n"; + +//$_local_doc = $bag['documentation'][ $_globals['language'] ]; +$_local_doc = str_replace( "\n", " ", $bag ); +$_local_doc = str_replace( "\t", "", $_local_doc ); +while( strlen( $_local_doc ) > 0 ) +{ + if ( preg_match( "/(.{0,70}[^\s]*)(\s*)/", $_local_doc, $matches ) ) + { + // Print blocks of 70 chars thru the next word + print $indent ." * " . $matches[1] . "\n"; + + // Account for any newlines + /*$n_newlines = preg_match_all( "/\n/", $matches[2], $buf ); + if ( $n_newlines > 0 ) + { + for( $i=0; $i<$n_newlines; $i++ ) { print " * \n"; } + }*/ + + // Find more lines... + $_local_doc = substr( $_local_doc, strlen( $matches[0] ) ); + } +} + +print $indent ." */\n"; +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.5/tpl/tpl-elements-file.php b/1.4.0/dom/codeGen/1.5/tpl/tpl-elements-file.php new file mode 100644 index 0000000..4e5694d --- /dev/null +++ b/1.4.0/dom/codeGen/1.5/tpl/tpl-elements-file.php @@ -0,0 +1,16 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +// Grab the file name and save the output +$_file = $_globals['prefix'] . "Elements.h"; +$_bytes = file_put_contents( ($_globals['target_dir'] . $_globals['dom_dir'] . 'include/' . $_file), applyTemplate( 'ELEMENTS', $bag ) ); + +//if ( $_bytes > 0 ) { print "Wrote $_bytes bytes to file '$_file'\n"; } + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.5/tpl/tpl-elements.php b/1.4.0/dom/codeGen/1.5/tpl/tpl-elements.php new file mode 100644 index 0000000..f16d2af --- /dev/null +++ b/1.4.0/dom/codeGen/1.5/tpl/tpl-elements.php @@ -0,0 +1,31 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +if ( $_globals['copyright'] ) { +print $_globals['copyright_text']; +} +?> +#ifndef __DOM_ELEMENTS_H__ +#define __DOM_ELEMENTS_H__ + +#include <<?= $_globals['prefix'] ?>/<?= $_globals['prefix'] ?>Types.h> + +<?php +//Base elements +foreach( $bag as $name => $meta ) { + $full_element_name = $_globals['prefix'] . ucfirst( $name ); + print "class " . $full_element_name . ";\n\n"; + print "typedef daeSmartRef<". $full_element_name ."> ". $full_element_name ."Ref;\n"; + print "typedef daeTArray<". $full_element_name ."Ref> ". $full_element_name ."_Array;\n\n"; +} + +?> + +#endif //__DOM_ELEMENTS_H__ + diff --git a/1.4.0/dom/codeGen/1.5/tpl/tpl-header.php b/1.4.0/dom/codeGen/1.5/tpl/tpl-header.php new file mode 100644 index 0000000..07dad80 --- /dev/null +++ b/1.4.0/dom/codeGen/1.5/tpl/tpl-header.php @@ -0,0 +1,16 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +// Grab the file name and save the output +$_file = $_globals['prefix'] . ucfirst( $bag['element_name'] ) . ".h"; +$_bytes = file_put_contents( ($_globals['target_dir'] . $_globals['dom_dir'] . 'include/' . $_file), applyTemplate( 'HEADER', $bag ) ); + +//if ( $_bytes > 0 ) { print "dom/" . $_globals['prefix'] . ucfirst( $bag['element_name'] ) . ".obj "; } + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.5/tpl/tpl-include-list.php b/1.4.0/dom/codeGen/1.5/tpl/tpl-include-list.php new file mode 100644 index 0000000..f09c278 --- /dev/null +++ b/1.4.0/dom/codeGen/1.5/tpl/tpl-include-list.php @@ -0,0 +1,13 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ +?>/* --- DO NOT REMOVE THIS LINE --- SNIP_SDK_COPYRIGHT_C_BEGIN + * --- DO NOT REMOVE THIS LINE --- SNIP_SDK_COPYRIGHT_C_END */ + +<?= implode( "\n", $_globals['include_list'] ) ?> + diff --git a/1.4.0/dom/codeGen/1.5/tpl/tpl-includes.php b/1.4.0/dom/codeGen/1.5/tpl/tpl-includes.php new file mode 100644 index 0000000..5228178 --- /dev/null +++ b/1.4.0/dom/codeGen/1.5/tpl/tpl-includes.php @@ -0,0 +1,42 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + + // INCLUDES + +$inc = array(); +global $meta; +global $includeList; +for( $i=0; $i<count( $bag['ref_elements'] ); $i++ ) +{ + if ( !in_array( $_globals['prefix'] . ucfirst( $bag['ref_elements'][$i] ), $includeList ) ) { + $inc[] = "#include <" . $_globals['prefix'] . "/" . $_globals['prefix'] . ucfirst( $bag['ref_elements'][$i] ) . ".h>"; + $includeList[] = $_globals['prefix'] . ucfirst( $bag['ref_elements'][$i] ); + } +} + +if($meta[$bag['content_type']]['isAComplexType']) { + if ( !in_array( $_globals['prefix'] . ucfirst( $bag['content_type'] ), $includeList ) ) { + $inc[] = "#include <" . $_globals['prefix'] . "/" . $_globals['prefix'] . ucfirst( $bag['content_type'] ) . ".h>"; + $includeList[] = $_globals['prefix'] . ucfirst( $bag['content_type'] ); + } +} + +if ( count( $inc ) ) { //only print if you have to include something + print implode( "\n", $inc ) . "\n"; +} + +$keys = array_keys( $bag['inline_elements'] ); +if ( count( $keys ) > 0 ) +{ + foreach( $keys as $k ) + { + print applyTemplate( 'INCLUDES', $bag['inline_elements'][ $k ] ); + } +} +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.5/tpl/tpl-types-cpp-file.php b/1.4.0/dom/codeGen/1.5/tpl/tpl-types-cpp-file.php new file mode 100644 index 0000000..16f15c6 --- /dev/null +++ b/1.4.0/dom/codeGen/1.5/tpl/tpl-types-cpp-file.php @@ -0,0 +1,16 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +// Grab the file name and save the output +$_file = $_globals['prefix'] . "Types.cpp"; +$_bytes = file_put_contents( ($_globals['target_dir'] . $_globals['dom_dir'] . 'src/' . $_file), applyTemplate( 'TYPES_CPP', $bag ) ); + +//if ( $_bytes > 0 ) { print "Wrote $_bytes bytes to file '$_file'\n"; } + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.5/tpl/tpl-types-cpp.php b/1.4.0/dom/codeGen/1.5/tpl/tpl-types-cpp.php new file mode 100644 index 0000000..7b649fb --- /dev/null +++ b/1.4.0/dom/codeGen/1.5/tpl/tpl-types-cpp.php @@ -0,0 +1,136 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +if ( $_globals['copyright'] ) { +print $_globals['copyright_text']; +} +?> +#include <dae.h> +#include <<?= $_globals['prefix'] . '/' . $_globals['prefix'] ?>Types.h> +#include <dae/daeDom.h> +#include <dom/domCOLLADA.h> + +<?php + +foreach( $bag as $type => $meta ) +{ + if ( $meta['isComplex'] ) { + ?>#include <<?= $_globals['prefix'] . '/' . $_globals['prefix'] . ucfirst( $type ) ?>.h> +<?php + } +} + +?> + +void registerDomTypes(DAE& dae) +{ + daeAtomicType* type = NULL; + daeAtomicTypeList& atomicTypes = dae.getAtomicTypes(); + +<?php + +foreach( $bag as $type => $meta ) +{ + if ( count( $meta['enum'] ) > 0 && !$meta['useConstStrings'] ) + {?> + // ENUM: <?= ucfirst( $type ) ?> + + type = new daeEnumType(dae); + type->_nameBindings.append("<?= ucfirst( $type ) ?>"); + ((daeEnumType*)type)->_strings = new daeStringRefArray; + ((daeEnumType*)type)->_values = new daeEnumArray; +<?php + foreach( $meta['enum'] as $val ) + {?> + ((daeEnumType*)type)->_strings->append("<?= $val ?>"); +<?php $val = str_replace( '.', '_', $val ); ?> + ((daeEnumType*)type)->_values->append(<?= strtoupper($type) . "_" . $val ?>); +<?php + } + print "\tatomicTypes.append( type );\n\n"; + } + elseif ( $meta['isComplex'] ) { + ?> + // COMPLEX TYPE: <?= ucfirst( $type ) ?> + + type = new daeElementRefType(dae); + type->_nameBindings.append("<?= ucfirst( $type ) ?>"); + atomicTypes.append( type ); + +<?php + } + /*else if ( $meta['union_type'] ) { //union type + ?> + // ENUM: <?= ucfirst( $type ) ?> + + type = new daeEnumType; + type->_nameBindings.append("<?= ucfirst( $type ) ?>"); + ((daeEnumType*)type)->_strings = new daeStringRefArray; + ((daeEnumType*)type)->_values = new daeEnumArray; +<?php + $types = explode( ' ', $meta['union_members'] ); + foreach ( $types as $typeName ) { + if ( isset( $bag[$typeName] ) && count($bag[$typeName]['enum']) > 0 ) { + foreach( $bag[$typeName]['enum'] as $val ) + {?> + ((daeEnumType*)type)->_strings->append("<?= $val ?>"); +<?php $val = str_replace( '.', '_', $val ); ?> + ((daeEnumType*)type)->_values->append(<?= strtoupper($type) . "_" . $val ?>); +<?php + } + } + } + print "\tatomicTypes.append( type );\n\n"; + } */ + else if ( !$meta['useConstStrings'] ) { //standard typedef + $base = strlen( $meta['base'] ) > 0 ? $meta['base'] : $meta['listType']; + if ( preg_match( "/xs\:/", $base ) ) { + $base = 'xs' . ucfirst( substr( $base, 3 ) ); + } + else { + $base = ucfirst( $base ); + } + ?> + // TYPEDEF: <?= ucfirst( $type ) ?> + //check if this type has an existing base +<?php + //special casing urifragment to be a xsURI for automatic resolution + if ( $type == 'urifragment' ) { + print "\ttype = atomicTypes.get(\"xsAnyURI\");\n"; + } + else { + print "\ttype = atomicTypes.get(\"". $base ."\");\n"; + } +?> + if ( type == NULL ) { //register as a raw type + type = new daeRawRefType(dae); + type->_nameBindings.append("<?= ucfirst( $type ) ?>"); + atomicTypes.append( type ); + } + else { //add binding to existing type + type->_nameBindings.append("<?= ucfirst( $type ) ?>"); + } + +<?php + } +} +?> +} + +daeMetaElement* registerDomElements(DAE& dae) +{ + daeMetaElement* meta = domCOLLADA::registerElement(dae); + // Enable tracking of top level object by default + meta->setIsTrackableForQueries(true); + return meta; +} + +daeInt DLLSPEC colladaTypeCount() { + return <?php /* +1 for <any> */ print ($_globals['typeID']+1); ?>; +} diff --git a/1.4.0/dom/codeGen/1.5/tpl/tpl-types-header-file.php b/1.4.0/dom/codeGen/1.5/tpl/tpl-types-header-file.php new file mode 100644 index 0000000..e635bae --- /dev/null +++ b/1.4.0/dom/codeGen/1.5/tpl/tpl-types-header-file.php @@ -0,0 +1,16 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +// Grab the file name and save the output +$_file = $_globals['prefix'] . "Types.h"; +$_bytes = file_put_contents( ($_globals['target_dir'] . $_globals['dom_dir'] . 'include/' . $_file), applyTemplate( 'TYPES_HEADER', $bag ) ); + +//if ( $_bytes > 0 ) { print "Wrote $_bytes bytes to file '$_file'\n"; } + +?>
\ No newline at end of file diff --git a/1.4.0/dom/codeGen/1.5/tpl/tpl-types-header.php b/1.4.0/dom/codeGen/1.5/tpl/tpl-types-header.php new file mode 100644 index 0000000..b8ad940 --- /dev/null +++ b/1.4.0/dom/codeGen/1.5/tpl/tpl-types-header.php @@ -0,0 +1,172 @@ +<?php +/* +* Copyright 2006 Sony Computer Entertainment Inc. +* +* Licensed under the MIT Open Source License, for details please see license.txt or the website +* http://www.opensource.org/licenses/mit-license.php +* +*/ + +if ( $_globals['copyright'] ) { +print $_globals['copyright_text']; +} +?> +#ifndef __DOM_TYPES_H__ +#define __DOM_TYPES_H__ + +#include <dae/daeDomTypes.h> + +<?php +//BASIC TYPES +foreach( $bag as $type => $meta ) +{ + if ( count( $meta['enum'] ) == 0 && !$meta['isComplex'] ) { + if ( strlen( $meta['base'] ) > 0 ) { //has a base type + if ( preg_match( "/xs\:/", $meta['base'] ) ) { + $base = substr( $meta['base'], 3 ); + $pre = 'xs'; + } + else { + $base = $meta['base']; + $pre = $_globals['prefix']; + } + if ( isset( $meta['documentation']['en'] ) ) { + print applyTemplate( 'DOXYGEN', $meta['documentation']['en'] ); + } + //special casing urifragment to be a xsURI for automatic resolution + if ( $type == 'urifragment' ) { + print "typedef xsAnyURI\t\tdomUrifragment;\n"; + } + else { + print "typedef " . $pre . ucfirst($base) . "\t\t" . $_globals['prefix'] . ucfirst( $type ) . ";\n"; + } + } + elseif ( strlen( $meta['listType'] ) > 0 ) { //is a list type + if ( isset( $meta['documentation']['en'] ) ) { + print applyTemplate( 'DOXYGEN', $meta['documentation']['en'] ); + } + if ( preg_match( "/xs\:/", $meta['listType'] ) ) { + $lt = substr( $meta['listType'], 3 ); + print "typedef xs" . ucfirst($lt) . "Array\t\t" . $_globals['prefix'] . ucfirst( $type ) . ";\n"; + } + else { + $lt = $meta['listType']; + print "typedef daeTArray<" . $_globals['prefix'] . ucfirst($lt) . ">\t\t" . $_globals['prefix'] . ucfirst( $type ) . ";\n"; + } + } + } +} + +print "\n"; + +//ENUMS +foreach( $bag as $type => $meta ) +{ + if ( count( $meta['enum'] ) > 0 ) + { + if ( !$meta['useConstStrings'] ) { + //Decided to name mangle the enum constants so they are more descriptive and avoid collisions + if ( isset( $meta['documentation']['en'] ) ) { + print applyTemplate( 'DOXYGEN', $meta['documentation']['en'] ); + } + print "enum " . $_globals['prefix'] . ucfirst( $type ) . " {\n"; + for( $i = 0; $i < count( $meta['enum'] ); $i++ ) { + $val = $meta['enum'][$i]; + $val = str_replace( '.', '_', $val ); + print "\t" . strtoupper( $type ) . "_" . $val; + if ( isset( $meta['enum_value'][$i] ) ) { + print " = ". $meta['enum_value'][$i]; + } + //else if ($i==0) { + // print " = 1"; + //} + print ","; + if ( isset( $meta['enum_documentation'][$i] ) ) { + print "\t\t/**< ". $meta['enum_documentation'][$i] ." */"; + } + print "\n"; + } + $cnt = count($meta['enum']); + //if ( !isset($meta['enum_value'][0]) ) { + // $cnt++; + //} + print "\t". strtoupper( $type ) . "_COUNT = ". $cnt; + print "\n};\n\n"; + } + else { + for( $i = 0; $i < count( $meta['enum'] ); $i++ ) { + if ( isset( $meta['enum_documentation'][$i] ) ) { + $_globals['constStrings'][] = "/**\n * ". $meta['enum_documentation'][$i] ."\n */\n"; + } + $conststrnm = strtoupper( $type ) . "_" . $meta['enum'][$i]; + $conststr = "\"". $meta['enum'][$i] ."\";\n"; + $_globals['constStrings'][$conststrnm] = $conststr; + } + $_globals['constStrings'][] = "\n"; + } + } +} + +//UNIONS +foreach( $bag as $type => & $meta ) +{ + if ( $meta['union_type'] ) + { + if ( isset( $meta['documentation']['en'] ) ) { + print applyTemplate( 'DOXYGEN', $meta['documentation']['en'] ); + } + print "enum " . $_globals['prefix'] . ucfirst( $type ) . " {\n"; + + //tokenize memberTypes string + $types = explode( ' ', $meta['union_members'] ); + //look up the members + $cnt = 1; + foreach ( $types as $typeName ) { + if ( isset( $bag[$typeName] ) && count($bag[$typeName]['enum']) > 0 ) { + //print all of their enum children + for( $i = 0; $i < count( $bag[$typeName]['enum'] ); $i++ ) { + $val = $bag[$typeName]['enum'][$i]; + $val = str_replace( '.', '_', $val ); + if ( in_array( $val, $meta['enum'] ) ) { + continue; + } + $meta['enum'][] = $val; + print "\t" . strtoupper( $type ) . "_" . $val; + if ( isset( $bag[$typeName]['enum_value'][$i] ) ) { + print " = ". $bag[$typeName]['enum_value'][$i]; + } + else if ($i==0) { + print " = 1"; + } + print ","; + if ( isset( $bag[$typeName]['enum_documentation'][$i] ) ) { + print "\t\t/**< ". $bag[$typeName]['enum_documentation'][$i] ." */"; + } + print "\n"; + $cnt++; + } + } + } + print "\t". strtoupper( $type ) . "_COUNT = ". $cnt; + print "\n};\n\n"; + } +} + +?> +//Element Type Enum +namespace COLLADA_TYPE +{ + const int + NO_TYPE = 0, + ANY = 1<?php + foreach( $_globals['elementTypes'] as $num => $val ) + print ",\n\t\t". getUniqueName($val, $_globals['elementTypes']) ." = ". ($num+2); + print ";" +?> + +} + +// Returns the total number of schema types/dom* classes +daeInt DLLSPEC colladaTypeCount(); + +#endif diff --git a/1.4.0/dom/codeGen/cleanSchema b/1.4.0/dom/codeGen/cleanSchema new file mode 100644 index 0000000..b3adacf --- /dev/null +++ b/1.4.0/dom/codeGen/cleanSchema @@ -0,0 +1,27 @@ +#!/bin/bash + +if [ ! -f "$1" ]; then + echo "Error: invalid schema" + echo "Usage: cleanSchema colladaSchema.xsd" + exit +fi + +newFile=`dirname "$1"`/`basename "$1" .xsd`_cleaned.xsd +cp "$1" "$newFile" + +# Remove type name annotations +perl -piU -e 's/_type"/"/g' "$newFile" +perl -piU -e 's/_group"/"/g' "$newFile" +perl -piU -e 's/_enum"/"/g' "$newFile" +perl -piU -e 's/_enum / /g' "$newFile" + +# node_type and node_enum both map down to node, which causes a +# conflict. Put back the _enum annotation on node_enum. +perl -piU -e 's/xs:simpleType name="node">/xs:simpleType name="node_enum">/g' "$newFile" +perl -piU -e 's/name="type" type="node"/name="type" type="node_enum"/g' "$newFile" + +# The DOM doesn't handle the mathml spec. Replace it with an xs:any so people +# can do whatever they want instead. +perl -piU -e 's/<xs:element ref="math:math"/<xs:any namespace="##any" processContents="skip" minOccurs="0" maxOccurs="unbounded"/g' "$newFile" + +rm "$newFile"U diff --git a/1.4.0/dom/codeGen/gen_dom_1_5 b/1.4.0/dom/codeGen/gen_dom_1_5 new file mode 100644 index 0000000..4ffc315 --- /dev/null +++ b/1.4.0/dom/codeGen/gen_dom_1_5 @@ -0,0 +1,21 @@ +#!/bin/bash + +if [ ! -f "$1" ]; then + echo "Error: invalid parameters" + echo "Usage: generate_dom_1_5 colladaSchema.xsd" + exit +fi + +echo cleaning schema ... +./cleanSchema "$1" +newFile=`dirname "$1"`/`basename "$1" .xsd`_cleaned.xsd + +cd 1.5 +echo generating dom ... +php gen.php ../$newFile +echo copying sources ... +mkdir -p ../../include/1.5/dom +mkdir -p ../../src/1.5/dom +cp gen/dom/include/* ../../include/1.5/dom +cp gen/dom/src/* ../../src/1.5/dom +cd .. diff --git a/1.4.0/dom/codeGen/readme.txt b/1.4.0/dom/codeGen/readme.txt new file mode 100644 index 0000000..a4492c6 --- /dev/null +++ b/1.4.0/dom/codeGen/readme.txt @@ -0,0 +1,24 @@ +Code generator usage +-------------------- + +php gen.php schema [cprt] + +schema: File name of the COLLADA schema document +cprt: Generate the files with an SCEA shared source copyright notice + +You'll need to download PHP for your platform. php 5.2.5 on Windows +is known to work while version 5.2.6 is known to cause problems. If you +get a ton of errors when you run the code generator on +Windows, try deleting C:\Program Files\PHP\php.ini if it's present. + +The code generator is branched between Collada 1.4 and 1.5. Use the code +generator branch that matches the schema version you're using. + +The code generator for Collada 1.5 requires some preprocessing of the +schema. This preprocessing is implemented as some perl search/replace one-liners +in a bash script called 'cleanSchema'. You'll need to have perl +installed. Although only a bash script is provided, it should be trivial to +adapt to a Windows batch file if that's what you need. Run cleanSchema like +this: 'cleanSchema collada15Schema.xsd'. It outputs a file named +collada15Schema_cleaned.xsd, which should then be run through the code generator +to create the 1.5 DOM sources. |