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

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

Issue 12041098: Initial commit of the Dart Chrome Extension APIs generators (Closed) Base URL: http://git.chromium.org/chromium/src.git@file_path_bugfix
Patch Set: Added wrappers for more types of functions (including events, callbacks and lists) Created 7 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 code import Code 5 from code import Code
6 from model import PropertyType, Type 6 from model import PropertyType, Type
7 import cpp_util 7 import cpp_util
8 import model 8 import model
9 import schema_util 9 import schema_util
10 import sys 10 import sys
11 import util_cc_helper 11 import util_cc_helper
12 12
13 class CCGenerator(object): 13 class CCGenerator(object):
14 def __init__(self, type_generator):
15 self._type_generator = type_generator
16
17 def Generate(self, namespace):
18 return _Generator(namespace, self._type_generator).Generate()
19
20 class _Generator(object):
14 """A .cc generator for a namespace. 21 """A .cc generator for a namespace.
15 """ 22 """
16 def __init__(self, namespace, cpp_type_generator): 23 def __init__(self, namespace, cpp_type_generator):
17 self._type_helper = cpp_type_generator 24 self._type_helper = cpp_type_generator
18 self._namespace = namespace 25 self._namespace = namespace
19 self._target_namespace = ( 26 self._target_namespace = (
20 self._type_helper.GetCppNamespaceName(self._namespace)) 27 self._type_helper.GetCppNamespaceName(self._namespace))
21 self._util_cc_helper = ( 28 self._util_cc_helper = (
22 util_cc_helper.UtilCCHelper(self._type_helper)) 29 util_cc_helper.UtilCCHelper(self._type_helper))
23 30
(...skipping 778 matching lines...) Expand 10 before | Expand all | Expand 10 after
802 """ 809 """
803 c = Code() 810 c = Code()
804 underlying_type = self._type_helper.FollowRef(prop.type_) 811 underlying_type = self._type_helper.FollowRef(prop.type_)
805 if (underlying_type.property_type == PropertyType.ENUM and 812 if (underlying_type.property_type == PropertyType.ENUM and
806 prop.optional): 813 prop.optional):
807 c.Append('%s->%s = %s;' % ( 814 c.Append('%s->%s = %s;' % (
808 dst, 815 dst,
809 prop.unix_name, 816 prop.unix_name,
810 self._type_helper.GetEnumNoneValue(prop.type_))) 817 self._type_helper.GetEnumNoneValue(prop.type_)))
811 return c 818 return c
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698