parameters: (self, f, idx, type_code)
docstring: Create a check for the idx parameter to be of given type.
docstring_summary: Create a check for the idx parameter to be of given type.
docstring_tokens: Create a check for the idx parameter to be of given type .
function: def gen_type_check(self, f, idx, type_code):
  		"""Create a check for the idx parameter to be of given type."""
  		atomic_chk = self.get_atomic_type_kind(type_code)
  
  		self.write(f, "f_type->get_parameter(%s, p_type, p_sym);\n" % idx)
  		self.write(f, "p_type = p_type->skip_type_alias();\n")
  		if atomic_chk:
  			code = """
  			if (p_type->get_kind() != %s) {
  				return false;
  			}
  			""" % atomic_chk
  			self.format_code(f, code)
  		elif type_code[0] == 'E':
  			# check for enum type only, should be enough, we do not expect overloads with different
  			# enum types
  			code = """
  				if (p_type->get_kind() != mi::mdl::IType::TK_ENUM) {
  					return false;
  				}
  			"""
  			self.format_code(f, code)
  		elif type_code[0] == 'U':
  			# unsupported types
  			code = ""
  		elif type_code[1] == 'A':
  			# handle arrays
  			code = "{\n";
  			code += """
  			if (p_type->get_kind() != mi::mdl::IType::TK_ARRAY) {
  				return false;
  			}
  			mi::mdl::IType_array const *a_type = mi::mdl::cast<mi::mdl::IType_array>(p_type);
  			(void)a_type;
  			"""
  			if type_code[2] == 'N' or type_code[2] == 'n':
  				# deferred size array
  				code += """
  				if (a_type->is_immediate_sized()) {
  					return false;
  				}
  				"""
  				if type_code[0] == 'F':
  					code += """
  					mi::mdl::IType const *e_type = a_type->get_element_type();
  					if (e_type->get_kind() != mi::mdl::IType::TK_FLOAT) {
  						return false;
  					}
  					"""
  				else:
  					code += """
  					// Unsupported
  					return false;
  					"""
  					error("Unsupported type code " + type_code)
  			else:
  				code += """
  				// Unsupported
  				return false;
  				"""
  				error("Unsupported type code " + type_code)
  			code += "\n}\n"
  			self.format_code(f, code)
  		else:
  			vector_chk = self.get_vector_type_kind(type_code)
  			matrix_chk = self.get_matrix_type_kind(type_code)
  			text_shape = self.get_texture_shape(type_code)
  			if vector_chk:
  				params = {
  					"size"   : type_code[-1],
  					"e_kind" : vector_chk
  				}
  				code = """
  				if (mi::mdl::IType_vector const *v_type = as<mi::mdl::IType_vector>(p_type)) {
  					if (v_type->get_size() != %(size)s) {
  						return false;
  					}
  
  					mi::mdl::IType_atomic const *e_type = v_type->get_element_type();
  					if (e_type->get_kind() != %(e_kind)s) {
  						return false;
  					}
  				} else {
  					return false;
  				}
  				"""
  				self.format_code(f, code % params)
  			elif matrix_chk:
  				params = {
  					"columns" : type_code[-2],
  					"size"    : type_code[-1],
  					"e_kind"  : matrix_chk
  				}
  				code = """
  				if (mi::mdl::IType_matrix const *m_type = as<mi::mdl::IType_matrix>(p_type)) {
  					if (m_type->get_columns() != %(columns)s) {
  						return false;
  					}
  
  					mi::mdl::IType_vector const *v_type = m_type->get_element_type();
  					if (v_type->get_size() != %(size)s) {
  						return false;
  					}
  
  					mi::mdl::IType_atomic const *e_type = v_type->get_element_type();
  					if (e_type->get_kind() != %(e_kind)s) {
  						return false;
  					}
  				} else {
  					return false;
  				}
  				"""
  				self.format_code(f, code % params)
  			elif text_shape:
  				code = """
  				if (mi::mdl::IType_texture const *t_type = as<mi::mdl::IType_texture>(p_type)) {
  					if (t_type->get_shape() != %s) {
  						return false;
  					}
  				}
  				"""
  				self.format_code(f, code % text_shape)
  			else:
  				code = """
  				// Unsupported
  				return false;
  				"""
  				error("Unsupported type code " + type_code)
  				self.format_code(f, code)
function_tokens: def gen_type_check ( self , f , idx , type_code ) : atomic_chk = self . get_atomic_type_kind ( type_code ) self . write ( f , "f_type->get_parameter(%s, p_type, p_sym);\n" % idx ) self . write ( f , "p_type = p_type->skip_type_alias();\n" ) if atomic_chk : code = """
  			if (p_type->get_kind() != %s) {
  				return false;
  			}
  			""" % atomic_chk self . format_code ( f , code ) elif type_code [ 0 ] == 'E' : # check for enum type only, should be enough, we do not expect overloads with different # enum types code = """
  				if (p_type->get_kind() != mi::mdl::IType::TK_ENUM) {
  					return false;
  				}
  			""" self . format_code ( f , code ) elif type_code [ 0 ] == 'U' : # unsupported types code = "" elif type_code [ 1 ] == 'A' : # handle arrays code = "{\n" code += """
  			if (p_type->get_kind() != mi::mdl::IType::TK_ARRAY) {
  				return false;
  			}
  			mi::mdl::IType_array const *a_type = mi::mdl::cast<mi::mdl::IType_array>(p_type);
  			(void)a_type;
  			""" if type_code [ 2 ] == 'N' or type_code [ 2 ] == 'n' : # deferred size array code += """
  				if (a_type->is_immediate_sized()) {
  					return false;
  				}
  				""" if type_code [ 0 ] == 'F' : code += """
  					mi::mdl::IType const *e_type = a_type->get_element_type();
  					if (e_type->get_kind() != mi::mdl::IType::TK_FLOAT) {
  						return false;
  					}
  					""" else : code += """
  					// Unsupported
  					return false;
  					""" error ( "Unsupported type code " + type_code ) else : code += """
  				// Unsupported
  				return false;
  				""" error ( "Unsupported type code " + type_code ) code += "\n}\n" self . format_code ( f , code ) else : vector_chk = self . get_vector_type_kind ( type_code ) matrix_chk = self . get_matrix_type_kind ( type_code ) text_shape = self . get_texture_shape ( type_code ) if vector_chk : params = { "size" : type_code [ - 1 ] , "e_kind" : vector_chk } code = """
  				if (mi::mdl::IType_vector const *v_type = as<mi::mdl::IType_vector>(p_type)) {
  					if (v_type->get_size() != %(size)s) {
  						return false;
  					}
  
  					mi::mdl::IType_atomic const *e_type = v_type->get_element_type();
  					if (e_type->get_kind() != %(e_kind)s) {
  						return false;
  					}
  				} else {
  					return false;
  				}
  				""" self . format_code ( f , code % params ) elif matrix_chk : params = { "columns" : type_code [ - 2 ] , "size" : type_code [ - 1 ] , "e_kind" : matrix_chk } code = """
  				if (mi::mdl::IType_matrix const *m_type = as<mi::mdl::IType_matrix>(p_type)) {
  					if (m_type->get_columns() != %(columns)s) {
  						return false;
  					}
  
  					mi::mdl::IType_vector const *v_type = m_type->get_element_type();
  					if (v_type->get_size() != %(size)s) {
  						return false;
  					}
  
  					mi::mdl::IType_atomic const *e_type = v_type->get_element_type();
  					if (e_type->get_kind() != %(e_kind)s) {
  						return false;
  					}
  				} else {
  					return false;
  				}
  				""" self . format_code ( f , code % params ) elif text_shape : code = """
  				if (mi::mdl::IType_texture const *t_type = as<mi::mdl::IType_texture>(p_type)) {
  					if (t_type->get_shape() != %s) {
  						return false;
  					}
  				}
  				""" self . format_code ( f , code % text_shape ) else : code = """
  				// Unsupported
  				return false;
  				""" error ( "Unsupported type code " + type_code ) self . format_code ( f , code )