xod-arduino
Advanced tools
Comparing version 0.35.3 to 0.36.0
@@ -35,2 +35,4 @@ // Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE | ||
var isSetImmediateEnabled = Directives$XodArduino.isSetImmediateEnabled; | ||
var stripCppComments = Directives$XodArduino.stripCppComments; | ||
@@ -44,2 +46,3 @@ | ||
exports.areTimeoutsEnabled = areTimeoutsEnabled; | ||
exports.isSetImmediateEnabled = isSetImmediateEnabled; | ||
exports.stripCppComments = stripCppComments; | ||
@@ -46,0 +49,0 @@ exports.findXodPragmas = findXodPragmas; |
@@ -131,2 +131,6 @@ // Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE | ||
function isSetImmediateEnabled(code) { | ||
return toBoolean(lastPragmaEndis(code, "immediate"), doesReferSymbol("setImmediate", code)); | ||
} | ||
function isNodeIdEnabled(code) { | ||
@@ -237,2 +241,3 @@ return toBoolean(lastPragmaEndis(code, "nodeid"), doesReferSymbol("getNodeId", code)); | ||
exports.areTimeoutsEnabled = areTimeoutsEnabled; | ||
exports.isSetImmediateEnabled = isSetImmediateEnabled; | ||
exports.isNodeIdEnabled = isNodeIdEnabled; | ||
@@ -239,0 +244,0 @@ exports.doesRaiseErrors = doesRaiseErrors; |
@@ -90,5 +90,12 @@ 'use strict'; | ||
var GENERATIVE_IMPLEMENTATION = ''; | ||
var getPatchImpl = (0, _types.def)('getPatchImpl :: Patch -> String', R.cond([ | ||
// exceptions | ||
[XP.isRecordPatch, R.always(GENERATIVE_IMPLEMENTATION)], [XP.isUnpackRecordPatch, R.always(GENERATIVE_IMPLEMENTATION)], [R.T, function (patch) { | ||
return R.compose((0, _xodFuncTools.explodeMaybe)('Implementation for ' + XP.getPatchPath(patch) + ' not found'), XP.getImpl)(patch); | ||
}]])); | ||
var convertPatchToTPatch = (0, _types.def)('convertPatchToTPatch :: Patch -> TPatch', function (patch) { | ||
var patchPath = XP.getPatchPath(patch); | ||
var impl = (0, _xodFuncTools.explodeMaybe)('Implementation for ' + patchPath + ' not found', XP.getImpl(patch)); | ||
var impl = getPatchImpl(patch); | ||
@@ -99,5 +106,24 @@ var isDirtyable = function isDirtyable(pin) { | ||
// Additional field for Patch outputs `recordField` | ||
// used only in code generation for unpack record patch. | ||
// It uses normalization of empty pin labels with opposite | ||
// directions, so if the unpack record patch has few outputs | ||
// with empty labels it will be normalized to `IN1`, `IN2` and so on. | ||
// This labels will be used in record proprty accessors (`record.IN1`), | ||
// while the outputs of unpack patch will be `OUT1` as usual. | ||
// | ||
// :: Map PinKey PinLabel | ||
// where PinLabel is normalized record field | ||
var recordFields = R.ifElse(function () { | ||
return XP.isUnpackRecordPatch(patch); | ||
}, R.compose(R.fromPairs, R.map(function (pin) { | ||
return [XP.getPinKey(pin), XP.getPinLabel(pin)]; | ||
}), R.map(R.over(pinLabelLens, _xodFuncTools.cppEscape)), XP.normalizeEmptyPinLabelsOppositeDirection, XP.listOutputPins), R.always({}))(patch); | ||
// :: PinKey -> Nullable PinLabel | ||
var getRecordField = R.ifElse(R.has(R.__, recordFields), R.prop(R.__, recordFields), R.always(null)); | ||
var outputs = R.compose(R.map(R.applySpec({ | ||
type: XP.getPinType, | ||
pinKey: XP.getPinLabel, | ||
recordField: R.compose(getRecordField, XP.getPinKey), | ||
value: R.compose(XP.defaultValueOfType, XP.getPinType), | ||
@@ -117,3 +143,6 @@ isDirtyable: isDirtyable, | ||
isConstant: XP.isConstantNodeType(patchPath), | ||
isRecord: XP.isRecordPatch(patch), | ||
isUnpackRecord: XP.isUnpackRecordPatch(patch), | ||
usesTimeouts: (0, _directives.areTimeoutsEnabled)(impl), | ||
usesSetImmediate: (0, _directives.isSetImmediateEnabled)(impl), | ||
catchesErrors: (0, _directives.doesCatchErrors)(impl), | ||
@@ -289,3 +318,3 @@ raisesErrors: (0, _directives.doesRaiseErrors)(impl), | ||
}); // if at least one input is whitelisted | ||
}, _directives.getEvaluateOnPinSettings, (0, _xodFuncTools.explodeMaybe)('Implementation for ' + XP.getPatchPath(patch) + ' not found'), XP.getImpl)(patch); | ||
}, _directives.getEvaluateOnPinSettings, getPatchImpl)(patch); | ||
@@ -292,0 +321,0 @@ return { |
@@ -95,2 +95,3 @@ 'use strict'; | ||
usesTimeouts: _sanctuaryDef2.default.Boolean, | ||
usesSetImmediate: _sanctuaryDef2.default.Boolean, | ||
catchesErrors: _sanctuaryDef2.default.Boolean, | ||
@@ -97,0 +98,0 @@ raisesErrors: _sanctuaryDef2.default.Boolean, |
{ | ||
"name": "xod-arduino", | ||
"version": "0.35.3", | ||
"version": "0.36.0", | ||
"description": "XOD project: Arduino transpiler", | ||
@@ -34,3 +34,3 @@ "scripts": { | ||
"xod-func-tools": "^0.34.0", | ||
"xod-project": "^0.35.2" | ||
"xod-project": "^0.36.0" | ||
}, | ||
@@ -42,3 +42,3 @@ "devDependencies": { | ||
"onchange": "^5.2.0", | ||
"xod-fs": "^0.35.2" | ||
"xod-fs": "^0.36.0" | ||
}, | ||
@@ -45,0 +45,0 @@ "files": [ |
@@ -35,2 +35,4 @@ // Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE | ||
var isSetImmediateEnabled = Directives$XodArduino.isSetImmediateEnabled; | ||
var stripCppComments = Directives$XodArduino.stripCppComments; | ||
@@ -44,2 +46,3 @@ | ||
exports.areTimeoutsEnabled = areTimeoutsEnabled; | ||
exports.isSetImmediateEnabled = isSetImmediateEnabled; | ||
exports.stripCppComments = stripCppComments; | ||
@@ -46,0 +49,0 @@ exports.findXodPragmas = findXodPragmas; |
@@ -124,2 +124,6 @@ // Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE | ||
function isSetImmediateEnabled(code) { | ||
return toBoolean(lastPragmaEndis(code, "immediate"), doesReferSymbol("setImmediate", code)); | ||
} | ||
function isNodeIdEnabled(code) { | ||
@@ -232,2 +236,3 @@ return toBoolean(lastPragmaEndis(code, "nodeid"), doesReferSymbol("getNodeId", code)); | ||
exports.areTimeoutsEnabled = areTimeoutsEnabled; | ||
exports.isSetImmediateEnabled = isSetImmediateEnabled; | ||
exports.isNodeIdEnabled = isNodeIdEnabled; | ||
@@ -234,0 +239,0 @@ exports.doesRaiseErrors = doesRaiseErrors; |
@@ -31,2 +31,5 @@ import * as R from 'ramda'; | ||
import recordImplementation from '../platform/nodes/record.tpl.cpp'; | ||
import unpackRecordImplementation from '../platform/nodes/unpackRecord.tpl.cpp'; | ||
// ============================================================================= | ||
@@ -395,2 +398,6 @@ // | ||
); | ||
registerHandlebarsFilterLoopHelper( | ||
'eachNodeUsingSetImmediate', | ||
R.path(['patch', 'usesSetImmediate']) | ||
); | ||
registerHandlebarsFilterLoopHelper('eachLinkedTweakNode', isLinkedTweakNode); | ||
@@ -457,2 +464,9 @@ registerHandlebarsFilterLoopHelper('eachTweakStringNode', isTweakStringNode); | ||
program: Handlebars.compile(programTpl, renderingOptions), | ||
nodes: { | ||
record: Handlebars.compile(recordImplementation, renderingOptions), | ||
unpackRecord: Handlebars.compile( | ||
unpackRecordImplementation, | ||
renderingOptions | ||
), | ||
}, | ||
}; | ||
@@ -482,3 +496,7 @@ | ||
export const renderImpl = def('renderImpl :: TPatch -> String', tPatch => { | ||
const impl = R.prop('impl', tPatch); | ||
const impl = R.cond([ | ||
[R.prop('isRecord'), templates.nodes.record], | ||
[R.prop('isUnpackRecord'), templates.nodes.unpackRecord], | ||
[R.T, R.prop('impl')], | ||
])(tPatch); | ||
const generatedCode = renderPatchContext(tPatch); | ||
@@ -485,0 +503,0 @@ const patchPinTypes = renderPatchPinTypes(tPatch); |
@@ -24,2 +24,3 @@ import * as R from 'ramda'; | ||
areTimeoutsEnabled, | ||
isSetImmediateEnabled, | ||
isNodeIdEnabled, | ||
@@ -121,2 +122,22 @@ doesRaiseErrors, | ||
const GENERATIVE_IMPLEMENTATION = ''; | ||
const getPatchImpl = def( | ||
'getPatchImpl :: Patch -> String', | ||
R.cond([ | ||
// exceptions | ||
[XP.isRecordPatch, R.always(GENERATIVE_IMPLEMENTATION)], | ||
[XP.isUnpackRecordPatch, R.always(GENERATIVE_IMPLEMENTATION)], | ||
[ | ||
R.T, | ||
patch => | ||
R.compose( | ||
explodeMaybe( | ||
`Implementation for ${XP.getPatchPath(patch)} not found` | ||
), | ||
XP.getImpl | ||
)(patch), | ||
], | ||
]) | ||
); | ||
const convertPatchToTPatch = def( | ||
@@ -126,6 +147,3 @@ 'convertPatchToTPatch :: Patch -> TPatch', | ||
const patchPath = XP.getPatchPath(patch); | ||
const impl = explodeMaybe( | ||
`Implementation for ${patchPath} not found`, | ||
XP.getImpl(patch) | ||
); | ||
const impl = getPatchImpl(patch); | ||
@@ -136,2 +154,30 @@ const isDirtyable = pin => | ||
// Additional field for Patch outputs `recordField` | ||
// used only in code generation for unpack record patch. | ||
// It uses normalization of empty pin labels with opposite | ||
// directions, so if the unpack record patch has few outputs | ||
// with empty labels it will be normalized to `IN1`, `IN2` and so on. | ||
// This labels will be used in record proprty accessors (`record.IN1`), | ||
// while the outputs of unpack patch will be `OUT1` as usual. | ||
// | ||
// :: Map PinKey PinLabel | ||
// where PinLabel is normalized record field | ||
const recordFields = R.ifElse( | ||
() => XP.isUnpackRecordPatch(patch), | ||
R.compose( | ||
R.fromPairs, | ||
R.map(pin => [XP.getPinKey(pin), XP.getPinLabel(pin)]), | ||
R.map(R.over(pinLabelLens, cppEscape)), | ||
XP.normalizeEmptyPinLabelsOppositeDirection, | ||
XP.listOutputPins | ||
), | ||
R.always({}) | ||
)(patch); | ||
// :: PinKey -> Nullable PinLabel | ||
const getRecordField = R.ifElse( | ||
R.has(R.__, recordFields), | ||
R.prop(R.__, recordFields), | ||
R.always(null) | ||
); | ||
const outputs = R.compose( | ||
@@ -142,2 +188,3 @@ R.map( | ||
pinKey: XP.getPinLabel, | ||
recordField: R.compose(getRecordField, XP.getPinKey), | ||
value: R.compose(XP.defaultValueOfType, XP.getPinType), | ||
@@ -173,3 +220,6 @@ isDirtyable, | ||
isConstant: XP.isConstantNodeType(patchPath), | ||
isRecord: XP.isRecordPatch(patch), | ||
isUnpackRecord: XP.isUnpackRecordPatch(patch), | ||
usesTimeouts: areTimeoutsEnabled(impl), | ||
usesSetImmediate: isSetImmediateEnabled(impl), | ||
catchesErrors: doesCatchErrors(impl), | ||
@@ -442,6 +492,3 @@ raisesErrors: doesRaiseErrors(impl), | ||
getEvaluateOnPinSettings, | ||
explodeMaybe( | ||
`Implementation for ${XP.getPatchPath(patch)} not found` | ||
), | ||
XP.getImpl | ||
getPatchImpl | ||
)(patch); | ||
@@ -448,0 +495,0 @@ |
@@ -76,2 +76,3 @@ import * as R from 'ramda'; | ||
usesTimeouts: $.Boolean, | ||
usesSetImmediate: $.Boolean, | ||
catchesErrors: $.Boolean, | ||
@@ -78,0 +79,0 @@ raisesErrors: $.Boolean, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
480365
71
3998
- Removednanoid@2.1.11(transitive)
- Removedshortid@2.2.16(transitive)
- Removedxod-project@0.35.2(transitive)
Updatedxod-project@^0.36.0