Skip to content
Permalink
Browse files

feat(api): change scriptAPI to uncurry

  • Loading branch information...
yyc-git committed Apr 6, 2019
1 parent af83229 commit a66f6ef74fe51ae3a176bed9cb4fe7c56652799f
@@ -1,10 +1,36 @@
let create = () => {
"unsafeGetScriptAttribute": OperateScriptDataMainService.unsafeGetScriptAttribute,
"unsafeGetScriptAttributeFieldValue": OperateScriptAttributeDataMainService.unsafeGetScriptAttributeFieldValue,
"setScriptAttributeFieldValue": OperateScriptDataMainService.setScriptAttributeFieldValue,
"unsafeGetScriptGameObject": ScriptAPI.unsafeGetScriptGameObject,
"getTransformLocalPosition": TransformAPI.getTransformLocalPosition,
"setTransformLocalPosition": TransformAPI.setTransformLocalPosition,
"unsafeGetGameObjectTransformComponent": GameObjectAPI.unsafeGetGameObjectTransformComponent,
"disposeGameObject": GameObjectAPI.disposeGameObject,
"unsafeGetScriptAttribute":
(. script, scriptAttributeName, state) =>
OperateScriptDataMainService.unsafeGetScriptAttribute(
script,
scriptAttributeName,
state,
),
"unsafeGetScriptAttributeFieldValue":
(. fieldName, attribute) =>
OperateScriptAttributeDataMainService.unsafeGetScriptAttributeFieldValue(
fieldName,
attribute,
),
"setScriptAttributeFieldValue":
(. script, (scriptAttributeName, fieldName, value), state) =>
OperateScriptDataMainService.setScriptAttributeFieldValue(
script,
(scriptAttributeName, fieldName, value),
state,
),
"unsafeGetScriptGameObject":
(. script, state) => ScriptAPI.unsafeGetScriptGameObject(script, state),
"getTransformLocalPosition":
(. transform, state) =>
TransformAPI.getTransformLocalPosition(transform, state),
"setTransformLocalPosition":
(. transform, localPosition, state) =>
TransformAPI.setTransformLocalPosition(transform, localPosition, state),
"unsafeGetGameObjectTransformComponent":
(. gameObject, state) =>
GameObjectAPI.unsafeGetGameObjectTransformComponent(gameObject, state),
"disposeGameObject":
(. gameObject, state) =>
GameObjectAPI.disposeGameObject(gameObject, state),
};
@@ -191,27 +191,28 @@ and arcballCameraControllerRecord = {
and scriptAPIJsObj = {
.
"unsafeGetScriptAttribute":
(int, string, state) => ScriptAttributeType.scriptAttribute,
(. int, string, state) => ScriptAttributeType.scriptAttribute,
"unsafeGetScriptAttributeFieldValue":
(string, ScriptAttributeType.scriptAttribute) =>
(. string, ScriptAttributeType.scriptAttribute) =>
ScriptAttributeType.scriptAttributeValue,
"unsafeGetScriptGameObject": (int, state) => int,
"unsafeGetScriptGameObject": (. int, state) => int,
"setScriptAttributeFieldValue":
(
.
int,
(string, string, ScriptAttributeType.scriptAttributeValue),
state
) =>
state,
"getTransformLocalPosition":
(transform, state) =>
(. transform, state) =>
(
Js.Typed_array.Float32Array.elt,
Js.Typed_array.Float32Array.elt,
Js.Typed_array.Float32Array.elt,
),
"setTransformLocalPosition":
(
(.
transform,
(
Js.Typed_array.Float32Array.elt,
@@ -222,8 +223,8 @@ and scriptAPIJsObj = {
) =>
state,
"unsafeGetGameObjectTransformComponent":
(GameObjectPrimitiveType.gameObject, state) => int,
"disposeGameObject": (GameObjectPrimitiveType.gameObject, state) => state,
(. GameObjectPrimitiveType.gameObject, state) => int,
"disposeGameObject": (. GameObjectPrimitiveType.gameObject, state) => state,
}
and apiRecord = {
scriptAPIJsObj,
@@ -135,7 +135,7 @@ module API = {
let unsafeGetScriptAttributeFieldValue =
api##unsafeGetScriptAttributeFieldValue;

unsafeGetScriptAttributeFieldValue(fieldName, scriptAttribute)
unsafeGetScriptAttributeFieldValue(. fieldName, scriptAttribute)
|> ScriptAttributeType.scriptAttributeValueToInt;
};

@@ -144,6 +144,7 @@ module API = {
let setScriptAttributeFieldValue = api##setScriptAttributeFieldValue;

setScriptAttributeFieldValue(
.
script,
(
scriptAttributeName,
@@ -159,7 +160,7 @@ module API = {
let unsafeGetScriptAttributeFieldValue =
api##unsafeGetScriptAttributeFieldValue;

unsafeGetScriptAttributeFieldValue(fieldName, scriptAttribute)
unsafeGetScriptAttributeFieldValue(. fieldName, scriptAttribute)
|> ScriptAttributeType.scriptAttributeValueToFloat;
};

@@ -168,6 +169,7 @@ module API = {
let setScriptAttributeFieldValue = api##setScriptAttributeFieldValue;

setScriptAttributeFieldValue(
.
script,
(
scriptAttributeName,
@@ -249,14 +251,15 @@ module TestCaseWithOneEventFuncAndOneAttribute = {

let transform =
unsafeGetGameObjectTransformComponent(
unsafeGetScriptGameObject(script, state),
.
unsafeGetScriptGameObject(. script, state),
state,
);

let (x, y, z) = getTransformLocalPosition(transform, state);
let (x, y, z) = getTransformLocalPosition(. transform, state);

let state =
setTransformLocalPosition(transform, (x +. 10., y, z), state);
setTransformLocalPosition(. transform, (x +. 10., y, z), state);

state;
};
@@ -268,7 +271,7 @@ module TestCaseWithOneEventFuncAndOneAttribute = {
let unsafeGetScriptAttribute = api##unsafeGetScriptAttribute;

let scriptAttribute =
unsafeGetScriptAttribute(script, scriptAttributeName, state);
unsafeGetScriptAttribute(. script, scriptAttributeName, state);

let state =
API.setScriptAttributeIntFieldValue(
@@ -291,7 +294,7 @@ module TestCaseWithOneEventFuncAndOneAttribute = {
let unsafeGetScriptAttribute = api##unsafeGetScriptAttribute;

let scriptAttribute =
unsafeGetScriptAttribute(script, scriptAttributeName, state);
unsafeGetScriptAttribute(. script, scriptAttributeName, state);

let state =
API.setScriptAttributeFloatFieldValue(
@@ -427,9 +430,9 @@ module TestCaseWithOneEventFuncAndTwoAttributes = {
let unsafeGetScriptAttribute = api##unsafeGetScriptAttribute;

let scriptAttribute1 =
unsafeGetScriptAttribute(script, scriptAttribute1Name, state);
unsafeGetScriptAttribute(. script, scriptAttribute1Name, state);
let scriptAttribute2 =
unsafeGetScriptAttribute(script, scriptAttribute2Name, state);
unsafeGetScriptAttribute(. script, scriptAttribute2Name, state);

let state =
API.setScriptAttributeFloatFieldValue(
@@ -581,9 +584,9 @@ module TestCaseWithTwoEventFuncsAndTwoAttributes = {
let unsafeGetScriptAttribute = api##unsafeGetScriptAttribute;

let scriptAttribute1 =
unsafeGetScriptAttribute(script, scriptAttribute1Name, state);
unsafeGetScriptAttribute(. script, scriptAttribute1Name, state);
let scriptAttribute2 =
unsafeGetScriptAttribute(script, scriptAttribute2Name, state);
unsafeGetScriptAttribute(. script, scriptAttribute2Name, state);

let state =
API.setScriptAttributeIntFieldValue(
@@ -614,9 +617,9 @@ module TestCaseWithTwoEventFuncsAndTwoAttributes = {
let unsafeGetScriptAttribute = api##unsafeGetScriptAttribute;

let scriptAttribute1 =
unsafeGetScriptAttribute(script, scriptAttribute1Name, state);
unsafeGetScriptAttribute(. script, scriptAttribute1Name, state);
let scriptAttribute2 =
unsafeGetScriptAttribute(script, scriptAttribute2Name, state);
unsafeGetScriptAttribute(. script, scriptAttribute2Name, state);

let state =
API.setScriptAttributeFloatFieldValue(

0 comments on commit a66f6ef

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