The codegen now can properly lookup array types.
Array type lookup failed previously because the typemapping class was not yet receiving the list of types from the database. Fix was to pass this data
This commit is contained in:
parent
287073afdc
commit
be0064f730
8 changed files with 34 additions and 20 deletions
|
|
@ -6,13 +6,16 @@
|
|||
#include "StructureTemplate.h"
|
||||
#include "TypeMappings.h"
|
||||
#include "Pgsql_oids.h"
|
||||
#include "PgDatabaseCatalog.h"
|
||||
|
||||
using namespace Pgsql;
|
||||
|
||||
std::shared_ptr<const TypeMappings> GetPglabCppTypeMappings()
|
||||
class PgTypeContainer;
|
||||
|
||||
std::shared_ptr<const TypeMappings> GetPglabCppTypeMappings(std::shared_ptr<const PgTypeContainer> types)
|
||||
{
|
||||
auto tm = std::make_shared<TypeMappings>();
|
||||
*tm = {
|
||||
auto tm = std::make_shared<TypeMappings>(types, std::initializer_list<TypeMappings::Mapping>
|
||||
{
|
||||
{ bool_oid, "bool" },
|
||||
{ char_oid, "char" },
|
||||
{ name_oid, "std::string" },
|
||||
|
|
@ -23,7 +26,7 @@ std::shared_ptr<const TypeMappings> GetPglabCppTypeMappings()
|
|||
{ oid_oid, "Oid" },
|
||||
{ float4_oid, "float" },
|
||||
{ float8_oid, "double" }
|
||||
};
|
||||
});
|
||||
tm->setDefaultStringType("std::string");
|
||||
tm->setDefaultContainerType("std::vector<%1>");
|
||||
return tm;
|
||||
|
|
@ -66,10 +69,10 @@ for (auto row: result) {
|
|||
}
|
||||
|
||||
|
||||
std::shared_ptr<LanguageConfig> buildPglabCppLanguageConfig()
|
||||
std::shared_ptr<LanguageConfig> buildPglabCppLanguageConfig(std::shared_ptr<PgDatabaseCatalog> catalog)
|
||||
{
|
||||
auto config = std::make_shared<LanguageConfig>();
|
||||
config->setTypeMappings(GetPglabCppTypeMappings());
|
||||
config->setTypeMappings(GetPglabCppTypeMappings(catalog->types()));
|
||||
config->setNameManglingRules(std::make_shared<NameManglingRules>());
|
||||
config->setStructureTemplate(buildPglabStructureTemplate());
|
||||
config->setIndentationConfig(std::make_shared<IndentationConfig>());
|
||||
|
|
@ -78,9 +81,9 @@ std::shared_ptr<LanguageConfig> buildPglabCppLanguageConfig()
|
|||
}
|
||||
|
||||
|
||||
std::shared_ptr<const LanguageConfig> getPglabCppLanguageConfig()
|
||||
std::shared_ptr<const LanguageConfig> getPglabCppLanguageConfig(std::shared_ptr<PgDatabaseCatalog> catalog)
|
||||
{
|
||||
static auto config = buildPglabCppLanguageConfig();
|
||||
static auto config = buildPglabCppLanguageConfig(catalog);
|
||||
return config;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue