File: tpl-types-cpp.php

package info (click to toggle)
collada-dom 2.4.4%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: buster, stretch
  • size: 17,096 kB
  • sloc: cpp: 156,849; php: 4,567; makefile: 38; sh: 32; python: 14
file content (136 lines) | stat: -rw-r--r-- 3,538 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
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); ?>;
}