Skip to content
Permalink
Browse files

feat(api): scriptAPI add more apis

  • Loading branch information...
yyc-git committed Apr 8, 2019
1 parent 3fff71b commit 0be975d6c57acc4ae94c7a98e19d8f77e330a800
@@ -23,11 +23,16 @@ let removeScriptEventFunctionData =
);

let replaceScriptEventFunctionData =
(script, scriptEventFunctionDataName, scriptEventFunctionData, state) =>
(
script,
(sourceScriptEventFunctionDataName, targetScriptEventFunctionDataName),
targetScriptEventFunctionData,
state,
) =>
OperateScriptDataMainService.replaceScriptEventFunctionData(
script,
scriptEventFunctionDataName,
scriptEventFunctionData,
(sourceScriptEventFunctionDataName, targetScriptEventFunctionDataName),
targetScriptEventFunctionData,
state,
);

@@ -53,24 +58,40 @@ let removeScriptAttribute = (script, scriptAttributeName, state) =>
);

let replaceScriptAttribute =
(script, scriptAttributeName, scriptAttribute, state) =>
(
script,
(sourceScriptAttributeName, targetScriptAttributeName),
targetScriptAttribute,
state,
) =>
OperateScriptDataMainService.replaceScriptAttribute(
script,
scriptAttributeName,
scriptAttribute,
(sourceScriptAttributeName, targetScriptAttributeName),
targetScriptAttribute,
state,
);

let unsafeGetScriptAttributeEntries = (script, state) =>
OperateScriptDataMainService.unsafeGetScriptAttributeEntries(script, state);

let unsafeGetScriptAttribute = (script, attributeName, state) =>
let unsafeGetScriptAttribute = (script, scriptAttributeName, state) =>
OperateScriptDataMainService.unsafeGetScriptAttribute(
script,
attributeName,
scriptAttributeName,
state,
);

let unsafeGetScriptAttributeFieldDefaultValue =
(script, scriptAttributeName, fieldName, state) =>
OperateScriptDataMainService.unsafeGetScriptAttribute(
script,
scriptAttributeName,
state,
)
|> OperateScriptAttributeDataMainService.unsafeGetScriptAttributeFieldDefaultValue(
fieldName,
);

let setScriptAttributeFieldDefaultValueAndValue =
(script, scriptAttributeName, fieldName, value, state) =>
OperateScriptDataMainService.setScriptAttributeFieldDefaultValueAndValue(
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
@@ -184,18 +184,36 @@ let removeScriptAttribute =
};

let replaceScriptEventFunctionData =
(script, scriptEventFunctionDataName, scriptEventFunctionData, state) =>
removeScriptEventFunctionData(script, scriptEventFunctionDataName, state)
(
script,
(sourceScriptEventFunctionDataName, targetScriptEventFunctionDataName),
targetScriptEventFunctionData,
state,
) =>
removeScriptEventFunctionData(
script,
sourceScriptEventFunctionDataName,
state,
)
|> addScriptEventFunctionData(
script,
scriptEventFunctionDataName,
scriptEventFunctionData,
targetScriptEventFunctionDataName,
targetScriptEventFunctionData,
);

let replaceScriptAttribute =
(script, scriptAttributeName, scriptAttribute, state) =>
removeScriptAttribute(script, scriptAttributeName, state)
|> addScriptAttribute(script, scriptAttributeName, scriptAttribute);
(
script,
(sourceScriptAttributeName, targetScriptAttributeName),
targetScriptAttribute,
state,
) =>
removeScriptAttribute(script, sourceScriptAttributeName, state)
|> addScriptAttribute(
script,
targetScriptAttributeName,
targetScriptAttribute,
);

let getScriptEventFunctionDataEntries = (script, {scriptRecord} as state) => {
let {scriptEventFunctionDataMap} as scriptRecord = scriptRecord;
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
No changes.
@@ -273,7 +273,7 @@ let _ =
let state =
ScriptAPI.replaceScriptEventFunctionData(
script,
scriptEventFunctionDataName1,
(scriptEventFunctionDataName1, scriptEventFunctionDataName1),
scriptEventFunctionData2,
state,
);
@@ -309,13 +309,44 @@ let _ =
let state =
ScriptAPI.replaceScriptAttribute(
script,
scriptAttributeName1,
(scriptAttributeName1, scriptAttributeName2),
scriptAttribute2,
state,
);

ScriptAPI.unsafeGetScriptAttributeEntries(script, state)
|> expect == [|(scriptAttributeName1, scriptAttribute2)|];
|> expect == [|(scriptAttributeName2, scriptAttribute2)|];
})
);

describe("unsafeGetScriptAttributeFieldDefaultValue", () =>
test("unsafe get script->attribute->field->default value", () => {
let (state, script) = ScriptAPI.createScript(state^);
let state =
ScriptTool.TestCaseWithOneEventFuncAndOneAttribute.buildScriptData(
~script,
~state,
(),
);
let newValue = 3;

let state =
ScriptAPI.setScriptAttributeFieldDefaultValueAndValue(
script,
ScriptTool.TestCaseWithOneEventFuncAndOneAttribute.getScriptAttributeName(),
"a",
newValue |> ScriptAttributeType.intToScriptAttributeValue,
state,
);

ScriptAPI.unsafeGetScriptAttributeFieldDefaultValue(
script,
ScriptTool.TestCaseWithOneEventFuncAndOneAttribute.getScriptAttributeName(),
"a",
state,
)
|> ScriptAttributeType.scriptAttributeValueToInt
|> expect == newValue;
})
);

0 comments on commit 0be975d

Please sign in to comment.
You can’t perform that action at this time.