Skip to content

Commit

Permalink
fix: Make small adjustment to interface template and engine logic
Browse files Browse the repository at this point in the history
  • Loading branch information
ksentak committed Jul 1, 2024
1 parent b39da1e commit 7187fa2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
4 changes: 2 additions & 2 deletions languages/cpp/templates/codeblocks/interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

ProviderInvokeSession(methodName, jsonParameters, err);
}
static void ProviderResultSession(std::string methodName, std::string& correlationId, ${provider.xresponse.name} result, Firebolt::Error *err = nullptr)
static void ProviderResultSession(std::string methodName, std::string& correlationId, ${provider.xresponse.name} result, Firebolt::Error *err = nullptr)
{
JsonObject jsonParameters;
WPEFramework::Core::JSON::Variant CorrelationId(correlationId);
Expand All @@ -34,7 +34,7 @@
${provider.xresponse.serialization}
ProviderInvokeSession(methodName, jsonParameters, err);
}
static void ProviderErrorSession(std::string methodName, std::string& correlationId, ${provider.xerror.name} result, Firebolt::Error *err = nullptr)
static void ProviderErrorSession(std::string methodName, std::string& correlationId, ${provider.xerror.name} result, Firebolt::Error *err = nullptr)
{
JsonObject jsonParameters;
WPEFramework::Core::JSON::Variant CorrelationId(correlationId);
Expand Down
16 changes: 4 additions & 12 deletions src/macrofier/engine.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const { isObject, isArray, propEq, pathSatisfies, propSatisfies } = predicates

import { isRPCOnlyMethod, isProviderInterfaceMethod, getProviderInterface, getPayloadFromEvent, providerHasNoParameters, isTemporalSetMethod, hasMethodAttributes, getMethodAttributes, isEventMethodWithContext, getSemanticVersion, getSetterFor, getProvidedCapabilities, isPolymorphicPullMethod, hasPublicAPIs, isAllowFocusMethod, hasAllowFocusMethods, createPolymorphicMethods, isExcludedMethod, isCallsMetricsMethod } from '../shared/modules.mjs'
import isEmpty from 'crocks/core/isEmpty.js'
import { getPath as getJsonPath, getLinkedSchemaPaths, getSchemaConstraints, isSchema, localizeDependencies, isDefinitionReferencedBySchema, mergeAnyOf, mergeOneOf, getSafeEnumKeyName, getPropertySchema } from '../shared/json-schema.mjs'
import { getPath as getJsonPath, getLinkedSchemaPaths, getSchemaConstraints, isSchema, localizeDependencies, isDefinitionReferencedBySchema, mergeAnyOf, mergeOneOf, getSafeEnumKeyName } from '../shared/json-schema.mjs'

// util for visually debugging crocks ADTs
const _inspector = obj => {
Expand Down Expand Up @@ -439,13 +439,6 @@ const promoteAndNameSubSchemas = (obj) => {
}
addContentDescriptorSubSchema(descriptor, '', obj)
}
if (tag['x-response']) {
const descriptor = {
name: obj.info.title,
schema: tag['x-response']
}
addContentDescriptorSubSchema(descriptor, '', obj)
}
})
}
})
Expand Down Expand Up @@ -1767,13 +1760,12 @@ function getProviderInterfaceName(iface, capability, moduleJson = {}) {
return name
}

function getProviderXValues(method, document) {
function getProviderXValues(method) {
let xValues = []
if (method.tags.find(t => t['x-error']) || method.tags.find(t => t['x-response'])) {
method.tags.forEach(tag => {
if (tag['x-response']) {
const resolvedRefResponse = getPropertySchema(tag['x-response'], '', document)
xValues['x-response'] = resolvedRefResponse
xValues['x-response'] = tag['x-response']
}
if (tag['x-error']) {
xValues['x-error'] = tag['x-error']
Expand Down Expand Up @@ -1838,7 +1830,7 @@ function insertProviderInterfaceMacros(template, capability, moduleJson = {}, te
if (!interfaceDeclaration) {
interfaceDeclaration = getTemplate(interfaceTemplate, templates)
}
xValues = getProviderXValues(method, moduleJson)
xValues = getProviderXValues(method)
method.tags.unshift({
name: 'provider'
})
Expand Down

0 comments on commit 7187fa2

Please sign in to comment.