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

Unified Diff: mojom/generators/c/cgen/type_translation.go

Issue 2074923002: Mojom C Generator: Small fixes to get generated C bindings to compile. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 6 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/generators/c/cgen/type_table.go ('k') | mojom/generators/c/templates/header.tmpl.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojom/generators/c/cgen/type_translation.go
diff --git a/mojom/generators/c/cgen/type_translation.go b/mojom/generators/c/cgen/type_translation.go
index 2fe92d64c4b8cc1b9654c9934dab2be6801ce546..ce0d6e221456d28ae6133b057ce1389f637d78bf 100644
--- a/mojom/generators/c/cgen/type_translation.go
+++ b/mojom/generators/c/cgen/type_translation.go
@@ -83,13 +83,13 @@ func isReservedKeyword(keyword string) bool {
return found
}
-// Translates: import "file.mojom" -> #include 'rel/path/file.mojom.c.h'
+// Translates: import "file.mojom" -> #include 'rel/path/file.mojom-c.h'
func mojomToCFilePath(srcRootPath string, mojomImport string) string {
rel_import, err := filepath.Rel(srcRootPath, mojomImport)
if err != nil {
log.Fatalf("Cannot determine relative path for '%s'", mojomImport)
}
- return rel_import + ".c.h"
+ return rel_import + "-c.h"
}
// Given an interface + method name, return a name-mangled name in C.
@@ -145,7 +145,7 @@ func mojomToCType(t mojom_types.Type, fileGraph *mojom_files.MojomFileGraph) str
case *mojom_types.TypeTypeReference:
typ_ref := t.Interface().(mojom_types.TypeReference)
if typ_ref.IsInterfaceRequest {
- return "MojoInterfaceRequestHandle"
+ return "MojoHandle"
}
resolved_type := fileGraph.ResolvedTypes[*typ_ref.TypeKey]
return userDefinedTypeToCType(&resolved_type)
@@ -170,17 +170,17 @@ func mojomToCLiteral(value mojom_types.LiteralValue) string {
case *mojom_types.LiteralValueInt16Value:
return strconv.FormatInt(int64(val.(int16)), 10)
case *mojom_types.LiteralValueInt32Value:
- return strconv.FormatInt(int64(val.(int32)), 10)
+ return strconv.FormatInt(int64(val.(int32)), 10) + "l"
case *mojom_types.LiteralValueInt64Value:
- return strconv.FormatInt(int64(val.(int64)), 10)
+ return strconv.FormatInt(int64(val.(int64)), 10) + "ll"
case *mojom_types.LiteralValueUint8Value:
return strconv.FormatUint(uint64(val.(uint8)), 10)
case *mojom_types.LiteralValueUint16Value:
return strconv.FormatUint(uint64(val.(uint16)), 10)
case *mojom_types.LiteralValueUint32Value:
- return strconv.FormatUint(uint64(val.(uint32)), 10)
+ return strconv.FormatUint(uint64(val.(uint32)), 10) + "ul"
case *mojom_types.LiteralValueUint64Value:
- return strconv.FormatUint(uint64(val.(uint64)), 10)
+ return strconv.FormatUint(uint64(val.(uint64)), 10) + "ull"
case *mojom_types.LiteralValueStringValue:
// TODO(vardhan): Do we have to do any string escaping here?
return "\"" + val.(string) + "\""
« no previous file with comments | « mojom/generators/c/cgen/type_table.go ('k') | mojom/generators/c/templates/header.tmpl.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698