Skip to content

Commit

Permalink
C++ generated code - use .obx.hpp and .obx.cpp extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
vaind committed Aug 14, 2020
1 parent 49c3174 commit 1d6b816
Show file tree
Hide file tree
Showing 12 changed files with 13 additions and 12 deletions.
3 changes: 2 additions & 1 deletion internal/generator/c/cgenerator.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func (gen *CGenerator) BindingFiles(forFile string, options generator.Options) [
if gen.PlainC {
return []string{base + ".obx.h"}
}
return []string{base + "-cpp.obx.h", base + ".obx.cpp"}
return []string{base + ".obx.hpp", base + ".obx.cpp"}
}

// ModelFile returns the model GO file for the given JSON info file path
Expand All @@ -64,6 +64,7 @@ func (CGenerator) IsGeneratedFile(file string) bool {
var name = filepath.Base(file)
return name == "objectbox-model.h" ||
strings.HasSuffix(name, ".obx.h") ||
strings.HasSuffix(name, ".obx.hpp") ||
strings.HasSuffix(name, ".obx.cpp")
}

Expand Down
2 changes: 1 addition & 1 deletion test/comparison/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ objectbox-model.[ch]

*.obx.go
*.obx.[ch]
*.obx.cpp
*.obx.[ch]pp
2 changes: 1 addition & 1 deletion test/comparison/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Therefore, the test works as follows:
* negative tests: if the file has a fail infix in the name: `*.fail.<source-type>`,
it's considered a negative test case (the generation should fail)
* `<source-type>/<test-case>/<target-type>/*.<target-type-ext>.expected` are files expected to be generated
e.g. `fbs/typeful/cpp/schema-cpp.obx.h`
e.g. `fbs/typeful/cpp/schema.obx.hpp`
* there's an exception with `go` source & target type = the target type isn't present in the path
e.g. `go/typeful/typebuf.obx.go.expected`
* `<source-type>/<test-case>/objectbox-model.json.expected` is the expected model JSON file, it's common for all languages.
Expand Down
2 changes: 1 addition & 1 deletion test/comparison/conf.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,6 @@ type testSpec struct {

var confs = map[string]testSpec{
"fbs-c": {"c", ".fbs", []string{".obx.h"}, &cgenerator.CGenerator{PlainC: true}, &cTestHelper{cpp: false}},
"fbs-cpp": {"cpp", ".fbs", []string{"-cpp.obx.h", ".obx.cpp"}, &cgenerator.CGenerator{PlainC: false}, &cTestHelper{cpp: true}},
"fbs-cpp": {"cpp", ".fbs", []string{".obx.hpp", ".obx.cpp"}, &cgenerator.CGenerator{PlainC: false}, &cTestHelper{cpp: true}},
"go": {"go", ".go", []string{".obx.go"}, &gogenerator.GoGenerator{}, &goTestHelper{}},
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Code generated by ObjectBox; DO NOT EDIT.

#include "schema-cpp.obx.h"
#include "schema.obx.hpp"

const obx::Property<Typeful, OBXPropertyType_Long> Typeful_::id(1);
const obx::Property<Typeful, OBXPropertyType_Int> Typeful_::int_(2);
Expand Down
2 changes: 1 addition & 1 deletion test/integration/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ CMakeLists.txt
objectbox-model.json
objectbox-model.[ch]
*.obx.[ch]
*.obx.cpp
*.obx.[ch]pp

# IDE
.idea/
Expand Down
2 changes: 1 addition & 1 deletion test/integration/property-clear/cpp/step-1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include "catch2/catch.hpp"
#include "objectbox-cpp.h"
#include "schema-cpp.obx.h"
#include "schema.obx.hpp"
#include "shared/store-init.h"
using namespace obx;

Expand Down
2 changes: 1 addition & 1 deletion test/integration/property-clear/cpp/step-2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include "catch2/catch.hpp"
#include "objectbox-cpp.h"
#include "schema-cpp.obx.h"
#include "schema.obx.hpp"
#include "shared/store-init.h"
using namespace obx;

Expand Down
2 changes: 1 addition & 1 deletion test/integration/renames/cpp/step-1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include "catch2/catch.hpp"
#include "objectbox-cpp.h"
#include "schema-cpp.obx.h"
#include "schema.obx.hpp"
#include "shared/store-init.h"
using namespace obx;

Expand Down
2 changes: 1 addition & 1 deletion test/integration/renames/cpp/step-2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include "catch2/catch.hpp"
#include "objectbox-cpp.h"
#include "schema-cpp.obx.h"
#include "schema.obx.hpp"
#include "shared/store-init.h"
using namespace obx;

Expand Down
4 changes: 2 additions & 2 deletions test/integration/typeful/cpp/main.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#define CATCH_CONFIG_MAIN

#include "annotated-cpp.obx.h"
#include "annotated.obx.hpp"
#include "catch2/catch.hpp"
#include "objectbox-cpp.h"
#include "objectbox-model.h"
#include "schema-cpp.obx.h"
#include "schema.obx.hpp"

using namespace obx;

Expand Down

0 comments on commit 1d6b816

Please sign in to comment.