Skip to content

Commit

Permalink
Ensure: method schemaShape generation is doing only for Modules
Browse files Browse the repository at this point in the history
  • Loading branch information
HaseenaSainul committed Jan 24, 2024
1 parent 6a648fa commit d3168de
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions languages/cpp/language.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"additionalMethodTemplates": [ "declarations", "declarations-override" ],
"templateExtensionMap": {
"methods": [ "impl.cpp", "cpp" ],
"declarations": ["h"],
"declarations-override": ["impl.h"]
"declarations": [ "h" ],
"declarations-override": [ "impl.h" ]
}
}
8 changes: 4 additions & 4 deletions src/macrofier/engine.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ const generateMacros = (obj, templates, languages, options = {}) => {
const eventsEnum = generateEvents(obj, templates)

const examples = generateExamples(obj, templates, languages)
const allMethodsArray = generateMethods(obj, examples, templates)
const allMethodsArray = generateMethods(obj, examples, templates, options.type)

Array.from(new Set(['methods'].concat(config.additionalMethodTemplates))).filter(dir => dir).forEach(dir => {

Expand Down Expand Up @@ -1169,7 +1169,7 @@ function generateMethodResult(type, templates) {
return result
}

function generateMethods(json = {}, examples = {}, templates = {}) {
function generateMethods(json = {}, examples = {}, templates = {}, type = '') {
const methods = compose(
option([]),
getMethods
Expand All @@ -1192,13 +1192,13 @@ function generateMethods(json = {}, examples = {}, templates = {}) {
if (dir.includes('declarations') && (suffix && config.templateExtensionMap[dir] ? config.templateExtensionMap[dir].includes(suffix) : true)) {
const template = getTemplateForDeclaration(methodObj, templates, dir)
if (template && template.length) {
result.declaration[dir] = insertMethodMacros(template, methodObj, json, templates, 'declarations', examples)
result.declaration[dir] = insertMethodMacros(template, methodObj, json, templates, '', examples)
}
}
else if (dir.includes('methods') && (suffix && config.templateExtensionMap[dir] ? config.templateExtensionMap[dir].includes(suffix) : true)) {
const template = getTemplateForMethod(methodObj, templates, dir)
if (template && template.length) {
result.body[dir] = insertMethodMacros(template, methodObj, json, templates, 'methods', examples)
result.body[dir] = insertMethodMacros(template, methodObj, json, templates, type, examples)
}
}
})
Expand Down
2 changes: 1 addition & 1 deletion src/macrofier/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -183,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

0 comments on commit d3168de

Please sign in to comment.