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

Unified Diff: mojom/mojom_tool/serialization/serialization.go

Issue 1916863003: Delete the |complete_type_set| field from mojom_types.mojom (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojom/mojom_tool/mojom/user_defined_types.go ('k') | mojom/mojom_tool/serialization/serialization_test.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojom/mojom_tool/serialization/serialization.go
diff --git a/mojom/mojom_tool/serialization/serialization.go b/mojom/mojom_tool/serialization/serialization.go
index bac56a60bb0f8e841928df38e1d3b7256928e53b..cf25fb714ce2853d368021775042e4c338ece7b9 100644
--- a/mojom/mojom_tool/serialization/serialization.go
+++ b/mojom/mojom_tool/serialization/serialization.go
@@ -32,10 +32,6 @@ var emitComputedPackingData bool = true
// runtime type info. This is useful in tests.
var emitSerializedRuntimeTypeInfo bool = true
-// By default we do not populate the complete type set of each top-level interface
-// because doing so is expensive and we are not currently using the the data.
-var populateCompleteTypeSet bool = false
-
// Serialize serializes the MojomDescriptor into a binary form that is passed to the
// backend of the compiler in order to invoke the code generators.
// To do this we use Mojo serialization.
@@ -43,18 +39,17 @@ var populateCompleteTypeSet bool = false
// of the serialized mojom_types.FileGraph.
// This function is not thread safe.
func Serialize(d *mojom.MojomDescriptor, debug bool) (bytes []byte, debugString string, err error) {
- return serialize(d, debug, true, true, true, false)
+ return serialize(d, debug, true, true, true)
}
// serialize() is a package-private version of the public method Serialize().
// It is intended for use in tests because it allows setting of the variables
-// emitLineAndColumnNumbers, emitComputedPackingData, emitSerializedRuntimeTypeInfo
-// and populateCompleteTypeSet.
+// emitLineAndColumnNumbers, emitComputedPackingData and emitSerializedRuntimeTypeInfo.
// This function is not thread safe because it sets and accesses these global
// variables.
func serialize(d *mojom.MojomDescriptor, debug,
- emitLineAndColumnNumbersParam, emitComputedPackingDataParam, emitSerializedRuntimeTypeInfoParam,
- populateCompleteTypeSetParam bool) (bytes []byte, debugString string, err error) {
+ emitLineAndColumnNumbersParam, emitComputedPackingDataParam,
+ emitSerializedRuntimeTypeInfoParam bool) (bytes []byte, debugString string, err error) {
// Save the global state and then set it based on the parameters.
saveEmitLineAndColumnNumbers := emitLineAndColumnNumbers
@@ -63,8 +58,6 @@ func serialize(d *mojom.MojomDescriptor, debug,
emitComputedPackingData = emitComputedPackingDataParam
saveEmitSerializedRuntimeTypeInfo := emitSerializedRuntimeTypeInfo
emitSerializedRuntimeTypeInfo = emitSerializedRuntimeTypeInfoParam
- savePopulateCompleteTypeSet := populateCompleteTypeSet
- populateCompleteTypeSet = populateCompleteTypeSetParam
fileGraph := translateDescriptor(d)
if debug {
@@ -79,7 +72,6 @@ func serialize(d *mojom.MojomDescriptor, debug,
emitLineAndColumnNumbers = saveEmitLineAndColumnNumbers
emitComputedPackingData = saveEmitComputedPackingData
emitSerializedRuntimeTypeInfo = saveEmitSerializedRuntimeTypeInfo
- populateCompleteTypeSet = savePopulateCompleteTypeSet
return
}
@@ -153,7 +145,7 @@ func translateMojomFile(f *mojom.MojomFile, fileGraph *mojom_files.MojomFileGrap
// the serialized bytes will form the |serialized_runtime_type_info| field
// of the MojomFile.
typeInfo := mojom_types.RuntimeTypeInfo{}
- typeInfo.ServicesByName = make(map[string]mojom_types.ServiceTypeInfo)
+ typeInfo.Services = make(map[string]string)
typeInfo.TypeMap = make(map[string]mojom_types.UserDefinedType)
// We populate the declared_mojom_objects field
@@ -166,7 +158,7 @@ func translateMojomFile(f *mojom.MojomFile, fileGraph *mojom_files.MojomFileGrap
typeKey := intrfc.TypeKey()
*(file.DeclaredMojomObjects.Interfaces) = append(*(file.DeclaredMojomObjects.Interfaces), typeKey)
- addServiceTypeInfo(intrfc, &typeInfo)
+ addServiceName(intrfc, &typeInfo)
typeInfo.TypeMap[typeKey] = fileGraph.ResolvedTypes[typeKey]
if intrfc.Enums != nil {
// Add embedded enums to typeInfo.TypeMap.
@@ -254,18 +246,13 @@ func translateMojomFile(f *mojom.MojomFile, fileGraph *mojom_files.MojomFileGrap
return
}
-// addServiceTypeInfo will add a ServiceTypeInfo to the ServicesByName field of |typeInfo| corresponding
-// to |intrfc| if |intrfc| is a top-level interface, meaning that it has a non-nil service name. In that
+// addServiceName will add the service name of |intrfc| to the |Services| field of |typeInfo|
+// if |intrfc| is a top-level interface, meaning that it has a non-nil service name. In that
// case this method returns true. Otherwise this method will do nothing and return fals.
-func addServiceTypeInfo(intrfc *mojom.MojomInterface, typeInfo *mojom_types.RuntimeTypeInfo) (isTopLevel bool) {
+func addServiceName(intrfc *mojom.MojomInterface, typeInfo *mojom_types.RuntimeTypeInfo) (isTopLevel bool) {
isTopLevel = intrfc.ServiceName != nil
if isTopLevel {
- serviceTypeInfo := mojom_types.ServiceTypeInfo{}
- serviceTypeInfo.TopLevelInterface = intrfc.TypeKey()
- if populateCompleteTypeSet {
- serviceTypeInfo.CompleteTypeSet = intrfc.FindReachableTypes()
- }
- typeInfo.ServicesByName[*intrfc.ServiceName] = serviceTypeInfo
+ typeInfo.Services[*intrfc.ServiceName] = intrfc.TypeKey()
}
return
}
« no previous file with comments | « mojom/mojom_tool/mojom/user_defined_types.go ('k') | mojom/mojom_tool/serialization/serialization_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698