mirror of
https://gitee.com/BDWare/cp.git
synced 2025-01-10 01:44:08 +00:00
add DO operation and multiple functions mapping relations
This commit is contained in:
parent
d040028463
commit
18b01e3ab0
@ -63,7 +63,9 @@ public class DebugMain {
|
|||||||
= new ResultCallback() {
|
= new ResultCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void onResult(String str) {
|
public void onResult(String str) {
|
||||||
|
if(str.contains("Error")) {
|
||||||
|
LOGGER.error("Some error happens: " + str);
|
||||||
|
}
|
||||||
LOGGER.info("[PrintCB] " + str);
|
LOGGER.info("[PrintCB] " + str);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -10,7 +10,7 @@ public abstract class AnnotationProcessor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void processFunction(
|
public void processFunction(
|
||||||
AnnotationNode anno, ContractNode contractNode, FunctionNode functionNode) {
|
AnnotationNode anno, ContractNode contractNode, FunctionNode functionNode) throws Exception {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -188,7 +188,7 @@ public class YJSCompiler {
|
|||||||
return czb;
|
return czb;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ContractNode compile(InputStream input, String fileName) throws IOException {
|
public ContractNode compile(InputStream input, String fileName) throws Exception {
|
||||||
// 词法分析
|
// 词法分析
|
||||||
JavaScriptLexer lexer = new JavaScriptLexer(new ANTLRInputStream(input));
|
JavaScriptLexer lexer = new JavaScriptLexer(new ANTLRInputStream(input));
|
||||||
lexer.setUseStrictDefault(true);
|
lexer.setUseStrictDefault(true);
|
||||||
@ -208,7 +208,7 @@ public class YJSCompiler {
|
|||||||
return contract;
|
return contract;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleAnnotation(ContractNode contractNode) {
|
private void handleAnnotation(ContractNode contractNode) throws Exception {
|
||||||
for (AnnotationNode node : contract.annotations) {
|
for (AnnotationNode node : contract.annotations) {
|
||||||
AnnotationProcessor processor = findProcessor(node);
|
AnnotationProcessor processor = findProcessor(node);
|
||||||
if (processor != null) {
|
if (processor != null) {
|
||||||
|
@ -13,7 +13,7 @@ import org.bdware.sc.node.FunctionNode;
|
|||||||
// DOOP is designed for DoipModule which contains specific functions for RepositoryHandler
|
// DOOP is designed for DoipModule which contains specific functions for RepositoryHandler
|
||||||
public class DOOP extends AnnotationProcessor {
|
public class DOOP extends AnnotationProcessor {
|
||||||
@Override
|
@Override
|
||||||
public void processFunction(AnnotationNode anno, ContractNode contractNode, FunctionNode functionNode) {
|
public void processFunction(AnnotationNode anno, ContractNode contractNode, FunctionNode functionNode) throws Exception {
|
||||||
// 通过DOOP注解,解析对应的值,并放进对应的FunctionNode中
|
// 通过DOOP注解,解析对应的值,并放进对应的FunctionNode中
|
||||||
// 注解必须暴露出来昂!!!
|
// 注解必须暴露出来昂!!!
|
||||||
functionNode.setIsExport(true);
|
functionNode.setIsExport(true);
|
||||||
|
@ -16,7 +16,6 @@ import org.bdware.sc.bean.ContractRequest;
|
|||||||
import org.bdware.sc.boundry.JavaScriptEntry;
|
import org.bdware.sc.boundry.JavaScriptEntry;
|
||||||
import org.bdware.sc.entity.DoipMessagePacker;
|
import org.bdware.sc.entity.DoipMessagePacker;
|
||||||
import org.bdware.sc.node.FunctionNode;
|
import org.bdware.sc.node.FunctionNode;
|
||||||
import org.bdware.sc.util.JsonUtil;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -41,8 +40,12 @@ public class DOOPRequestHandler implements DoipRequestHandler, RepositoryHandler
|
|||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addDoipOperation(FunctionNode function) {
|
public void addDoipOperation(FunctionNode function) throws Exception {
|
||||||
doipFunctionNodeMap.put(function.getDoipOperationInfo().operationName, function);
|
String operationName = function.getDoipOperationInfo().operationName;
|
||||||
|
if (doipFunctionNodeMap.containsKey(operationName)) {
|
||||||
|
throw new Exception("Contract is wrong: One DO operation maps multiple functions");
|
||||||
|
}
|
||||||
|
doipFunctionNodeMap.put(operationName, function);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -67,7 +67,7 @@ public class YJSParserTest {
|
|||||||
ContractNode cn = compiler.compile(resource, "rrr.yjs");
|
ContractNode cn = compiler.compile(resource, "rrr.yjs");
|
||||||
new DesktopEngine();
|
new DesktopEngine();
|
||||||
System.out.println(new Gson().toJson(cn));
|
System.out.println(new Gson().toJson(cn));
|
||||||
} catch (IOException e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user