Skip to content

Commit

Permalink
Optimization of generation time: generate macros only based on the sc…
Browse files Browse the repository at this point in the history
…hemhema template requirement if it is set (#165)
  • Loading branch information
HaseenaSainul authored Jan 31, 2024
1 parent 66c6feb commit 30e8133
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 40 deletions.
7 changes: 6 additions & 1 deletion languages/cpp/language.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,10 @@
"primitives": {},
"langVersion" : "c++17",
"additionalSchemaTemplates": [ "json-types" ],
"additionalMethodTemplates": [ "declarations", "declarations-override" ]
"additionalMethodTemplates": [ "declarations", "declarations-override" ],
"templateExtensionMap": {
"methods": [ "impl.cpp", "cpp" ],
"declarations": [ "h" ],
"declarations-override": [ "impl.h" ]
}
}
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
${if.modules}#include "${info.title.lowercase}_impl.h"
${end.if.modules}${module.includes.private}
${end.if.modules}${module.includes.private}
3 changes: 1 addition & 2 deletions languages/javascript/language.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
],
"createModuleDirectories": true,
"copySchemasIntoModules": true,
"aggregateFile": "/index.d.ts",
"aggregateFiles": [
"/index.d.ts"
],
Expand All @@ -25,4 +24,4 @@
"object": "object"
},
"additionalMethodTemplates": [ "declarations" ]
}
}
82 changes: 47 additions & 35 deletions src/macrofier/engine.mjs

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion src/macrofier/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ const macrofy = async (
convertTuplesToArraysOrObjects,
additionalSchemaTemplates,
additionalMethodTemplates,
templateExtensionMap,
excludeDeclarations,
extractProviderSchema,
aggregateFiles,
Expand Down Expand Up @@ -97,6 +98,7 @@ const macrofy = async (
allocatedPrimitiveProxies,
additionalSchemaTemplates,
additionalMethodTemplates,
templateExtensionMap,
excludeDeclarations,
extractProviderSchema,
operators
Expand Down Expand Up @@ -181,7 +183,7 @@ const macrofy = async (

// Pick the index and defaults templates for each module.
templatesPerModule.forEach(t => {
const macros = engine.generateMacros(module, templates, exampleTemplates, {hideExcluded: hideExcluded, copySchemasIntoModules: copySchemasIntoModules, createPolymorphicMethods: createPolymorphicMethods, destination: t})
const macros = engine.generateMacros(module, templates, exampleTemplates, {hideExcluded: hideExcluded, copySchemasIntoModules: copySchemasIntoModules, createPolymorphicMethods: createPolymorphicMethods, destination: t, type: 'methods'})
let content = getTemplateForModule(module.info.title, t, templates)

// NOTE: whichever insert is called first also needs to be called again last, so each phase can insert recursive macros from the other
Expand Down
1 change: 1 addition & 0 deletions src/sdk/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ const run = async ({
allocatedPrimitiveProxies: config.allocatedPrimitiveProxies,
additionalSchemaTemplates: config.additionalSchemaTemplates,
additionalMethodTemplates: config.additionalMethodTemplates,
templateExtensionMap: config.templateExtensionMap,
excludeDeclarations: config.excludeDeclarations,
extractProviderSchema: config.extractProviderSchema,
staticModuleNames: staticModuleNames,
Expand Down

0 comments on commit 30e8133

Please sign in to comment.