Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(321)

Side by Side Diff: tools/json_schema_compiler/cc_generator.py

Issue 9456007: Add wider support to json_schema_compiler (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 from model import PropertyType 5 from model import PropertyType
6 import code 6 import code
7 import cpp_util 7 import cpp_util
8 import util_cc_helper 8 import util_cc_helper
9 9
10 class CCGenerator(object): 10 class CCGenerator(object):
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 (c.Concat(self._GenerateFunction(function)) 65 (c.Concat(self._GenerateFunction(function))
66 .Append() 66 .Append()
67 ) 67 )
68 (c.Concat(self._cpp_type_generator.GetNamespaceEnd()) 68 (c.Concat(self._cpp_type_generator.GetNamespaceEnd())
69 .Concat(self._cpp_type_generator.GetRootNamespaceEnd()) 69 .Concat(self._cpp_type_generator.GetRootNamespaceEnd())
70 .Append() 70 .Append()
71 ) 71 )
72 # TODO(calamity): Events 72 # TODO(calamity): Events
73 return c 73 return c
74 74
75 def _GenerateType(self, cpp_namespace, type_, serializable=True): 75 def _GenerateType(self, cpp_namespace, type_):
76 """Generates the function definitions for a type. 76 """Generates the function definitions for a type.
77 """ 77 """
78 classname = cpp_util.Classname(type_.name) 78 classname = cpp_util.Classname(type_.name)
79 c = code.Code() 79 c = code.Code()
80 80
81 (c.Append('%(namespace)s::%(classname)s() {}') 81 (c.Concat(self._GeneratePropertyFunctions(
82 cpp_namespace, type_.properties.values()))
83 .Append('%(namespace)s::%(classname)s() {}')
82 .Append('%(namespace)s::~%(classname)s() {}') 84 .Append('%(namespace)s::~%(classname)s() {}')
83 .Append() 85 .Append()
84 .Concat(self._GenerateTypePopulate(cpp_namespace, type_)) 86 .Concat(self._GenerateTypePopulate(cpp_namespace, type_))
85 .Append() 87 .Append()
86 ) 88 )
87 if serializable: 89 if type_.serializable:
88 c.Concat(self._GenerateTypeToValue(cpp_namespace, type_)) 90 c.Concat(self._GenerateTypeToValue(cpp_namespace, type_))
89 c.Append() 91 c.Append()
90 c.Substitute({'classname': classname, 'namespace': cpp_namespace}) 92 c.Substitute({'classname': classname, 'namespace': cpp_namespace})
91 93
92 return c 94 return c
93 95
94 def _GenerateTypePopulate(self, cpp_namespace, type_): 96 def _GenerateTypePopulate(self, cpp_namespace, type_):
95 """Generates the function for populating a type given a pointer to it. 97 """Generates the function for populating a type given a pointer to it.
96 """ 98 """
97 classname = cpp_util.Classname(type_.name) 99 classname = cpp_util.Classname(type_.name)
(...skipping 24 matching lines...) Expand all
122 dst: Type* 124 dst: Type*
123 """ 125 """
124 c = code.Code() 126 c = code.Code()
125 value_var = prop.unix_name + '_value' 127 value_var = prop.unix_name + '_value'
126 c.Append('Value* %(value_var)s = NULL;') 128 c.Append('Value* %(value_var)s = NULL;')
127 if prop.optional: 129 if prop.optional:
128 (c.Sblock( 130 (c.Sblock(
129 'if (%(src)s->GetWithoutPathExpansion("%(key)s", &%(value_var)s)) {' 131 'if (%(src)s->GetWithoutPathExpansion("%(key)s", &%(value_var)s)) {'
130 ) 132 )
131 .Concat(self._GeneratePopulatePropertyFromValue( 133 .Concat(self._GeneratePopulatePropertyFromValue(
132 prop, value_var, 'out', 'false')) 134 prop, value_var, dst, 'false'))
133 .Eblock('}') 135 .Eblock('}')
134 ) 136 )
135 else: 137 else:
136 (c.Append( 138 (c.Append(
137 'if (!%(src)s->GetWithoutPathExpansion("%(key)s", &%(value_var)s))') 139 'if (!%(src)s->GetWithoutPathExpansion("%(key)s", &%(value_var)s))')
138 .Append(' return false;') 140 .Append(' return false;')
139 .Concat(self._GeneratePopulatePropertyFromValue( 141 .Concat(self._GeneratePopulatePropertyFromValue(
140 prop, value_var, 'out', 'false')) 142 prop, value_var, dst, 'false'))
141 ) 143 )
142 c.Append() 144 c.Append()
143 c.Substitute({'value_var': value_var, 'key': prop.name, 'src': src}) 145 c.Substitute({'value_var': value_var, 'key': prop.name, 'src': src})
144 return c 146 return c
145 147
146 def _GenerateTypeToValue(self, cpp_namespace, type_): 148 def _GenerateTypeToValue(self, cpp_namespace, type_):
147 """Generates a function that serializes the type into a |DictionaryValue|. 149 """Generates a function that serializes the type into a |DictionaryValue|.
148 """ 150 """
149 c = code.Code() 151 c = code.Code()
150 (c.Sblock('scoped_ptr<DictionaryValue> %s::ToValue() const {' % 152 (c.Sblock('scoped_ptr<DictionaryValue> %s::ToValue() const {' %
151 cpp_namespace) 153 cpp_namespace)
152 .Append('scoped_ptr<DictionaryValue> value(new DictionaryValue());') 154 .Append('scoped_ptr<DictionaryValue> value(new DictionaryValue());')
153 .Append() 155 .Append()
154 ) 156 )
155 for prop in type_.properties.values(): 157 for prop in type_.properties.values():
156 c.Concat(self._CreateValueFromProperty(prop, prop.unix_name, 'value')) 158 c.Concat(self._CreateValueFromProperty(prop, prop.unix_name, 'value'))
157 (c.Append() 159 (c.Append()
158 .Append('return value.Pass();') 160 .Append('return value.Pass();')
159 .Eblock('}') 161 .Eblock('}')
160 ) 162 )
161 return c 163 return c
162 164
163 def _CreateValueFromProperty(self, prop, var, dst): 165 def _CreateValueFromProperty(self, prop, var, dst):
not at google - send to devlin 2012/02/24 03:53:05 just noticed that dst isn't documented, can you do
164 """Generates code to serialize a single property in a type. 166 """Generates code to serialize a single property in a type.
165 167
166 prop: Property to create from 168 prop: Property to create from
167 var: variable with value to create from 169 var: variable with value to create from
168 """ 170 """
169 c = code.Code() 171 c = code.Code()
170 if prop.type_ == PropertyType.ENUM: 172 if prop.optional:
171 c.Sblock('switch (%s) {' % var) 173 if prop.type_ == PropertyType.ENUM:
172 for enum_value in prop.enum_values: 174 c.Sblock('if (%s != %s)' %
173 (c.Append('case %s: {' % 175 (var, self._cpp_type_generator.GetEnumNoneValue(prop)))
174 self._cpp_type_generator.GetEnumValue(prop, enum_value)) 176 else:
175 .Append(' %s->SetWithoutPathExpansion('
176 '"%s", Value::CreateStringValue("%s"));' %
177 (dst, prop.name, enum_value))
178 .Append(' break;')
179 .Append('}')
180 )
181 # C++ requires the entire enum to be handled by a switch.
182 if prop.optional:
183 (c.Append('case %s: {' %
184 self._cpp_type_generator.GetEnumNoneValue(prop))
185 .Append(' break;')
186 .Append('}')
187 )
188 c.Eblock('}')
189 else:
190 if prop.optional:
191 c.Sblock('if (%s.get())' % var) 177 c.Sblock('if (%s.get())' % var)
not at google - send to devlin 2012/02/24 03:53:05 will this work for CHOICES?
calamity 2012/02/24 15:10:40 No. There is currently no facility for turning a C
192 if prop.type_ == PropertyType.ARRAY: 178 c.Append('%s->SetWithoutPathExpansion("%s", %s);' % (
193 c.Append('%s;' % self._util_cc_helper.PopulateDictionaryFromArray( 179 dst,
194 prop, var, prop.name, dst)) 180 prop.name,
195 else: 181 cpp_util.CreateValueFromSingleProperty(
196 c.Append('%s->SetWithoutPathExpansion("%s", %s);' % 182 prop, var, self._util_cc_helper)))
197 (dst, prop.name, cpp_util.CreateValueFromSingleProperty(prop, var)))
198 return c 183 return c
199 184
200 def _GenerateFunction(self, function): 185 def _GenerateFunction(self, function):
201 """Generates the definitions for function structs. 186 """Generates the definitions for function structs.
202 """ 187 """
203 classname = cpp_util.Classname(function.name) 188 classname = cpp_util.Classname(function.name)
204 c = code.Code() 189 c = code.Code()
205 190
206 # Params::Populate function 191 # Params::Populate function
207 if function.params: 192 if function.params:
208 for param in function.params: 193 c.Concat(self._GeneratePropertyFunctions(classname + '::Params',
209 if param.type_ == PropertyType.OBJECT: 194 function.params))
210 param_namespace = '%s::Params::%s' % (classname,
211 cpp_util.Classname(param.name))
212 c.Concat(
213 self._GenerateType(param_namespace, param, serializable=False))
214 c.Append()
215 (c.Append('%(name)s::Params::Params() {}') 195 (c.Append('%(name)s::Params::Params() {}')
216 .Append('%(name)s::Params::~Params() {}') 196 .Append('%(name)s::Params::~Params() {}')
217 .Append() 197 .Append()
218 .Concat(self._GenerateFunctionParamsCreate(function)) 198 .Concat(self._GenerateFunctionParamsCreate(function))
219 .Append() 199 .Append()
220 ) 200 )
221 201
222 # Result::Create function 202 # Result::Create function
223 c.Concat(self._GenerateFunctionResultCreate(function)) 203 if function.callback:
204 c.Concat(self._GenerateFunctionResultCreate(function))
224 205
225 c.Substitute({'name': classname}) 206 c.Substitute({'name': classname})
226 207
227 return c 208 return c
228 209
210 def _GenerateCreateEnumValue(self, cpp_namespace, prop):
211 """Generates a function that returns the Value representation of an enum.
Yoyo Zhou 2012/02/24 04:02:22 Should this mention that they are string values?
calamity 2012/02/24 15:10:40 Done.
212 """
213 c = code.Code()
214 c.Append('// static')
215 c.Sblock('scoped_ptr<Value> %(namespace)s::CreateEnumValue(%(arg)s) {')
not at google - send to devlin 2012/02/24 03:53:05 call string substitution same name as variable, so
calamity 2012/02/24 15:10:40 Done.
216 c.Sblock('switch (%s) {' % prop.unix_name)
217 if prop.optional:
218 (c.Append('case %s: {' % self._cpp_type_generator.GetEnumNoneValue(prop))
219 .Append(' return scoped_ptr<Value>();')
220 .Append('}')
221 )
222 for enum_value in prop.enum_values:
223 (c.Append('case %s: {' %
224 self._cpp_type_generator.GetEnumValue(prop, enum_value))
225 .Append(' return scoped_ptr<Value>(Value::CreateStringValue("%s"));' %
226 enum_value)
227 .Append('}')
228 )
229 c.Eblock('}')
230 c.Eblock('}')
231 c.Substitute({
232 'namespace': cpp_namespace,
233 'arg': cpp_util.GetParameterDeclaration(
234 prop, self._cpp_type_generator.GetType(prop))
235 })
236 return c
237
229 def _GenerateParamsCheck(self, function, var): 238 def _GenerateParamsCheck(self, function, var):
230 """Generates a check for the correct number of arguments when creating 239 """Generates a check for the correct number of arguments when creating
231 Params. 240 Params.
232 """ 241 """
233 c = code.Code() 242 c = code.Code()
234 num_required = 0 243 num_required = 0
235 for param in function.params: 244 for param in function.params:
236 if not param.optional: 245 if not param.optional:
237 num_required += 1 246 num_required += 1
238 if num_required == len(function.params): 247 if num_required == len(function.params):
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 should be performed before the code this generates. 312 should be performed before the code this generates.
304 313
305 prop: the property the code is populating. 314 prop: the property the code is populating.
306 value_var: a Value* that should represent |prop|. 315 value_var: a Value* that should represent |prop|.
307 dst: the object with |prop| as a member. 316 dst: the object with |prop| as a member.
308 failure_value: the value to return if |prop| cannot be extracted from 317 failure_value: the value to return if |prop| cannot be extracted from
309 |value_var| 318 |value_var|
310 check_type: if true, will check if |value_var| is the correct Value::Type 319 check_type: if true, will check if |value_var| is the correct Value::Type
311 """ 320 """
312 c = code.Code() 321 c = code.Code()
322 c.Append('// %s' % prop.name)
not at google - send to devlin 2012/02/24 03:53:05 2 spaces between the // and the %s (sorry... yeah,
calamity 2012/02/24 15:10:40 Removed. This made the code uglier. I must have le
313 c.Sblock('{') 323 c.Sblock('{')
314 324
315 if check_type: 325 if check_type and prop.type_ != PropertyType.CHOICES:
316 (c.Append('if (!%(value_var)s->IsType(%(value_type)s))') 326 (c.Append('if (!%(value_var)s->IsType(%(value_type)s))')
317 .Append(' return %(failure_value)s;') 327 .Append(' return %(failure_value)s;')
318 ) 328 )
319 329
320 if prop.type_.is_fundamental: 330 if prop.type_.is_fundamental:
321 if prop.optional: 331 if prop.optional:
322 (c.Append('%(ctype)s temp;') 332 (c.Append('%(ctype)s temp;')
323 .Append('if (%s)' % 333 .Append('if (%s)' %
324 cpp_util.GetAsFundamentalValue(prop, value_var, '&temp')) 334 cpp_util.GetAsFundamentalValue(prop, value_var, '&temp'))
325 .Append(' %(dst)s->%(name)s.reset(new %(ctype)s(temp));') 335 .Append(' %(dst)s->%(name)s.reset(new %(ctype)s(temp));')
(...skipping 25 matching lines...) Expand all
351 elif prop.type_ == PropertyType.ARRAY: 361 elif prop.type_ == PropertyType.ARRAY:
352 # util_cc_helper deals with optional and required arrays 362 # util_cc_helper deals with optional and required arrays
353 (c.Append('ListValue* list = NULL;') 363 (c.Append('ListValue* list = NULL;')
354 .Append('if (!%(value_var)s->GetAsList(&list))') 364 .Append('if (!%(value_var)s->GetAsList(&list))')
355 .Append(' return %(failure_value)s;') 365 .Append(' return %(failure_value)s;')
356 .Append('if (!%s)' % self._util_cc_helper.PopulateArrayFromList( 366 .Append('if (!%s)' % self._util_cc_helper.PopulateArrayFromList(
357 prop, 'list', dst + '->' + prop.unix_name)) 367 prop, 'list', dst + '->' + prop.unix_name))
358 .Append(' return %(failure_value)s;') 368 .Append(' return %(failure_value)s;')
359 ) 369 )
360 elif prop.type_ == PropertyType.CHOICES: 370 elif prop.type_ == PropertyType.CHOICES:
361 return self._GeneratePopulateChoices(prop, value_var, dst, failure_value) 371 type_var = '%(dst)s->%(name)s_type'
372 c.Sblock('switch (%(value_var)s->GetType()) {')
373 for choice in self._cpp_type_generator.GetExpandedChoicesInParams([prop]):
374 (c.Sblock('case %s: {' % cpp_util.GetValueType(choice))
375 .Concat(self._GeneratePopulatePropertyFromValue(
376 choice, value_var, dst, failure_value, check_type=False))
377 .Append('%s = %s;' %
378 (type_var,
379 self._cpp_type_generator.GetEnumValue(
380 prop, choice.type_.name)))
381 .Append('break;')
382 .Eblock('}')
383 )
384 (c.Append('default:')
385 .Append(' return %(failure_value)s;')
386 )
387 c.Eblock('}')
362 elif prop.type_ == PropertyType.ENUM: 388 elif prop.type_ == PropertyType.ENUM:
363 (c.Append('std::string enum_temp;') 389 (c.Append('std::string enum_temp;')
364 .Append('if (!%(value_var)s->GetAsString(&enum_temp))') 390 .Append('if (!%(value_var)s->GetAsString(&enum_temp))')
365 .Append(' return %(failure_value)s;') 391 .Append(' return %(failure_value)s;')
366 ) 392 )
367 for i, enum_value in enumerate(prop.enum_values): 393 for i, enum_value in enumerate(prop.enum_values):
368 (c.Append( 394 (c.Append(
369 ('if' if i == 0 else 'else if') + 395 ('if' if i == 0 else 'else if') +
370 '(enum_temp == "%s")' % enum_value) 396 '(enum_temp == "%s")' % enum_value)
371 .Append(' %s->%s = %s;' % ( 397 .Append(' %s->%s = %s;' % (
372 dst, 398 dst,
373 prop.unix_name, 399 prop.unix_name,
374 self._cpp_type_generator.GetEnumValue(prop, enum_value))) 400 self._cpp_type_generator.GetEnumValue(prop, enum_value)))
375 ) 401 )
376 (c.Append('else') 402 (c.Append('else')
377 .Append(' return %(failure_value)s;') 403 .Append(' return %(failure_value)s;')
378 ) 404 )
379 else: 405 else:
380 raise NotImplementedError(prop.type_) 406 raise NotImplementedError(prop.type_)
381 c.Eblock('}') 407 c.Eblock('}')
382 c.Substitute({ 408 sub = {
383 'value_var': value_var, 409 'value_var': value_var,
384 'name': prop.unix_name, 410 'name': prop.unix_name,
385 'dst': dst, 411 'dst': dst,
386 'ctype': self._cpp_type_generator.GetType(prop),
387 'failure_value': failure_value, 412 'failure_value': failure_value,
388 'value_type': cpp_util.GetValueType(prop), 413 }
389 }) 414 if prop.type_ != PropertyType.CHOICES:
415 sub['ctype'] = self._cpp_type_generator.GetType(prop)
416 sub['value_type'] = cpp_util.GetValueType(prop)
417 c.Substitute(sub)
390 return c 418 return c
391 419
392 def _GeneratePopulateChoices(self, prop, value_var, dst, failure_value): 420 def _GeneratePropertyFunctions(self, param_namespace, params):
393 """Generates the code to populate a PropertyType.CHOICES parameter or 421 """Generate the structures required by a property such as functions OBJECT
394 property. The existence of data inside the Value* is assumed so checks for 422 properties and enum to Value conversion.
not at google - send to devlin 2012/02/24 03:53:05 Ugh, I don't understand how the method name and co
calamity 2012/02/24 15:10:40 Done.
395 existence should be performed before the code this generates.
396
397 prop: the property the code is populating..
398 value_var: a Value* that should represent |prop|.
399 dst: the object with |prop| as a member.
400 failure_value: the value to return if |prop| cannot be extracted from
401 |value_var|.
402 """ 423 """
403 type_var = '%s->%s_type' % (dst, prop.unix_name)
404
405 c = code.Code() 424 c = code.Code()
406 c.Sblock('switch (%s->GetType()) {' % value_var) 425 for param in params:
407 for choice in self._cpp_type_generator.GetExpandedChoicesInParams([prop]): 426 if param.type_ == PropertyType.OBJECT:
408 (c.Sblock('case %s: {' % cpp_util.GetValueType(choice)) 427 c.Concat(self._GenerateType(
409 .Concat(self._GeneratePopulatePropertyFromValue( 428 param_namespace + '::' + cpp_util.Classname(param.name),
410 choice, value_var, dst, failure_value, check_type=False)) 429 param))
411 .Append('%s = %s;' % 430 c.Append()
412 (type_var, 431 elif param.type_ == PropertyType.ENUM:
413 self._cpp_type_generator.GetEnumValue( 432 c.Concat(self._GenerateCreateEnumValue(param_namespace, param))
414 prop, choice.type_.name))) 433 c.Append()
415 .Append('break;')
416 .Eblock('}')
417 )
418 (c.Append('default:')
419 .Append(' return %s;' % failure_value)
420 )
421 c.Eblock('}')
422 return c 434 return c
423 435
424 def _GenerateFunctionResultCreate(self, function): 436 def _GenerateFunctionResultCreate(self, function):
425 """Generate function to create a Result given the return value. 437 """Generate function to create a Result given the return value.
426 """ 438 """
427 classname = cpp_util.Classname(function.name) 439 classname = cpp_util.Classname(function.name)
428 c = code.Code() 440 c = code.Code()
429 params = function.callback.params 441 params = function.callback.params
430 442
431 if not params: 443 if not params:
432 (c.Append('Value* %s::Result::Create() {' % classname) 444 (c.Append('Value* %s::Result::Create() {' % classname)
433 .Append(' return Value::CreateNullValue();') 445 .Append(' return Value::CreateNullValue();')
434 .Append('}') 446 .Append('}')
435 ) 447 )
436 else: 448 else:
449 expanded_params = self._cpp_type_generator.GetExpandedChoicesInParams(
450 params)
451 c.Concat(self._GeneratePropertyFunctions(
452 classname + '::Result', expanded_params))
not at google - send to devlin 2012/02/24 03:53:05 too much indentation
calamity 2012/02/24 15:10:40 Done.
453
437 # If there is a single parameter, this is straightforward. However, if 454 # If there is a single parameter, this is straightforward. However, if
438 # the callback parameter is of 'choices', this generates a Create method 455 # the callback parameter is of 'choices', this generates a Create method
439 # for each choice. This works because only 1 choice can be returned at a 456 # for each choice. This works because only 1 choice can be returned at a
440 # time. 457 # time.
441 for param in self._cpp_type_generator.GetExpandedChoicesInParams(params): 458 for param in expanded_params:
442 # We treat this argument as 'required' to avoid wrapping it in a 459 # We treat this argument as 'required' to avoid wrapping it in a
443 # scoped_ptr if it's optional. 460 # scoped_ptr if it's optional.
444 param_copy = param.Copy() 461 param_copy = param.Copy()
445 param_copy.optional = False 462 param_copy.optional = False
446 c.Sblock('Value* %(classname)s::Result::Create(const %(arg)s) {') 463 c.Sblock('Value* %(classname)s::Result::Create(const %(arg)s) {')
447 if param_copy.type_ == PropertyType.ARRAY: 464 c.Append('return %s;' %
448 (c.Append('ListValue* value = new ListValue();') 465 cpp_util.CreateValueFromSingleProperty(param_copy,
449 .Append('%s;' % self._util_cc_helper.PopulateListFromArray( 466 param_copy.unix_name, self._util_cc_helper))
450 param_copy, param_copy.unix_name, 'value')) 467 c.Eblock('}')
451 .Append('return value;')
452 )
453 else:
454 c.Append('return %s;' %
455 cpp_util.CreateValueFromSingleProperty(param_copy,
456 param_copy.unix_name))
457 c.Substitute({'classname': classname, 468 c.Substitute({'classname': classname,
458 'arg': cpp_util.GetParameterDeclaration( 469 'arg': cpp_util.GetParameterDeclaration(
459 param_copy, self._cpp_type_generator.GetType(param_copy)) 470 param_copy, self._cpp_type_generator.GetType(param_copy))
460 }) 471 })
461 c.Eblock('}')
462 472
463 return c 473 return c
464 474
465 def _InitializePropertyToDefault(self, prop, dst): 475 def _InitializePropertyToDefault(self, prop, dst):
466 """Initialize a model.Property to its default value inside an object. 476 """Initialize a model.Property to its default value inside an object.
467 477
468 dst: Type* 478 dst: Type*
469 """ 479 """
470 c = code.Code() 480 c = code.Code()
471 if prop.type_ in (PropertyType.ENUM, PropertyType.CHOICES): 481 if prop.type_ in (PropertyType.ENUM, PropertyType.CHOICES):
472 if prop.optional: 482 if prop.optional:
473 prop_name = prop.unix_name 483 prop_name = prop.unix_name
474 if prop.type_ == PropertyType.CHOICES: 484 if prop.type_ == PropertyType.CHOICES:
475 prop_name = prop.unix_name + '_type' 485 prop_name = prop.unix_name + '_type'
476 c.Append('%s->%s = %s;' % ( 486 c.Append('%s->%s = %s;' % (
477 dst, 487 dst,
478 prop_name, 488 prop_name,
479 self._cpp_type_generator.GetEnumNoneValue(prop))) 489 self._cpp_type_generator.GetEnumNoneValue(prop)))
480 return c 490 return c
481 491
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698