Skip to content

Commit

Permalink
Change code style for auto-generated code
Browse files Browse the repository at this point in the history
  • Loading branch information
Gene Gleyzer committed Jun 2, 2023
1 parent 8a55467 commit d16e4fa
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 61 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@

class %schemaName%Impl_(DboInfo_ info_)
extends DBSchemaImpl(info_)
implements %schemaTypeName%
{
implements %schemaTypeName% {
%PropertyGetters% %SchemaMethods% %ChildSchemas%
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@

class %propertyTypeName%Impl_(DboInfo_ info_, %propertyStoreType% store_)
extends %propertyBaseType%(info_, store_)
incorporates %propertyType%
{
incorporates %propertyType% {
// ----- mixin methods -----------------------------------------------------------------

%CustomMethods%
}
}
10 changes: 5 additions & 5 deletions lib_oodb/src/main/x/oodb/tools/templates/CustomInstantiation.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

case %propertyId%:
DboInfo_ info = this.%appName%Client_.infoFor(%propertyId%);
%propertyStoreType% store =
this.%appName%Client_.storeFor(%propertyId%).as(%propertyStoreType%);
return new %propertyTypeName%Impl_(info, store);
case %propertyId%:
DboInfo_ info = this.%appName%Client_.infoFor(%propertyId%);
%propertyStoreType% store =
this.%appName%Client_.storeFor(%propertyId%).as(%propertyStoreType%);
return new %propertyTypeName%Impl_(info, store);
10 changes: 4 additions & 6 deletions lib_oodb/src/main/x/oodb/tools/templates/CustomMethod.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@

@Override
%retType% %name%(%argsDecl%)
{
using (this.%appName%Client_.ensureTransaction(this))
{
%retType% %name%(%argsDecl%) {
using (this.%appName%Client_.ensureTransaction(this)) {
return super(%args%);
}
}
}
}
5 changes: 2 additions & 3 deletions lib_oodb/src/main/x/oodb/tools/templates/PropertyGetter.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@

@Override
%propertyType% %propertyName%.get()
{
%propertyType% %propertyName%.get() {
%propertyType% impl = this.%appName%Client_.implFor(%propertyId%).as(%propertyType%);
return &impl.maskAs(%propertyType%);
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@

@Override
class RootSchemaImpl(DboInfo_ info_)
implements RootSchema_
{
implements RootSchema_ {
%PropertyGetters%
%SchemaMethods%
}
}
%ChildSchemas%
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

case %schemaId%:
DboInfo_ info = this.%appName%Client_.infoFor(%schemaId%);
return new %schemaName%Impl_(info);
case %schemaId%:
DboInfo_ info = this.%appName%Client_.infoFor(%schemaId%);
return new %schemaName%Impl_(info);
59 changes: 24 additions & 35 deletions lib_oodb/src/main/x/oodb/tools/templates/_module.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
module %appName%_jsondb%qualifier%
incorporates jsondb_.CatalogMetadata<RootSchema_>
{
incorporates jsondb_.CatalogMetadata<RootSchema_> {
package oodb_ import oodb.xtclang.org;
package json_ import json.xtclang.org;
package jsondb_ import jsondb.xtclang.org;
Expand All @@ -16,37 +15,33 @@ module %appName%_jsondb%qualifier%
import %appName%_.%appSchema% as RootSchema_;

@Override
@RO Module schemaModule.get()
{
@RO Module schemaModule.get() {
assert Module m := %appName%_.isModuleImport();
return m;
}
}

@Override
@Lazy immutable DboInfo_[] dbObjectInfos.calc()
{
@Lazy immutable DboInfo_[] dbObjectInfos.calc() {
return
[
new DboInfo_(ROOT, DBSchema, 0, 0, [%ChildrenIds%], [%ChildrenNames%], False),
%PropertyInfos%
];
}
}

@Override
Map<String, Type> dbTypes.get()
{
Map<String, Type> dbTypes.get() {
return Map:
[
%PropertyTypes%
// TODO:
// "String"=String,
// "AddressBookDB_:Contact"=AddressBookDB_.Contact,
];
}
}

@Override
@Lazy json_.Schema jsonSchema.calc()
{
@Lazy json_.Schema jsonSchema.calc() {
return new json_.Schema(
schemaMappings = [], // TODO use dbTypes?
version = dbVersion,
Expand All @@ -56,50 +51,44 @@ module %appName%_jsondb%qualifier%
enableReflection = True,
typeSystem = &this.actualType.typeSystem,
);
}
}

@Override
Catalog_<RootSchema_> createCatalog(Directory dir, Boolean readOnly = False)
{
Catalog_<RootSchema_> createCatalog(Directory dir, Boolean readOnly = False) {
return new Catalog_<RootSchema_>(dir, this, readOnly);
}
}

@Override
Client_<RootSchema_> createClient(
Catalog_<RootSchema_> catalog,
Int clientId,
DBUser_ dbUser,
Boolean readOnly = False,
function void(Client_)? notifyOnClose = Null)
{
function void(Client_)? notifyOnClose = Null) {
return new %appName%Client_(catalog, clientId, dbUser, readOnly, notifyOnClose);
}
}

service %appName%Client_
extends Client_<RootSchema_>
{
extends Client_<RootSchema_> {
construct(Catalog_<RootSchema_> catalog,
Int clientId,
DBUser_ dbUser,
Boolean readOnly = False,
function void(Client_)? notifyOnClose = Null)
{
function void(Client_)? notifyOnClose = Null) {
construct Client_(catalog, clientId, dbUser, readOnly, notifyOnClose);
}
}

@Override
DBObjectImpl createImpl(Int id)
{
switch (id)
{
DBObjectImpl createImpl(Int id) {
switch (id) {
%CustomInstantiations%
default:
break;
}
default:
break;
}

return super(id);
}
}
%CustomDeclarations%
%RootSchema%
}
}
}
}

0 comments on commit d16e4fa

Please sign in to comment.