// Step 1902: Sprint 274 Integration // Full pipeline verified on poly-api (http-server/Go calls api-client/C++): // PolyglotProjectSpec → ABIBoundaryExtractor → FFIGlueDispatcher → CHeaderEmitter + DWARF // // t1: poly-api extracts correct boundary node (http-server/Go → api-client/C++) // t2: dispatcher routes Go→C++ to GoCppBindingEmitter (CGo import in goCode) // t3: C header generated from poly-api boundary nodes has extern "C" // t4: DWARF annotations include DW_TAG_subprogram for function boundary // t5: Sprint274IntegrationSummary reports correct counts and success #include "ABIBoundaryExtractor.h" #include "FFIGlueDispatcher.h" #include "CHeaderEmitter.h" #include "DWARFBoundaryAnnotator.h" #include "PolyApiProject.h" #include "Sprint274IntegrationSummary.h" #include #include #include using json = nlohmann::json; namespace ws = whetstone; static int p=0,f=0; #define T(n) { std::cout<<" "<<#n<<"... "; } #define P() { std::cout<<"PASS\n"; ++p; } #define F(m) { std::cout<<"FAIL: "<()); std::string goCode = result["secondaryCode"]; C(goCode.find("\"C\"") != std::string::npos || goCode.find("import") != std::string::npos, "Go side must have CGo import"); C(goCode.find("send_request") != std::string::npos || goCode.find("SendRequest") != std::string::npos, "Go side must reference send_request or SendRequest"); P(); } void t3(){ T(c_header_from_poly_api_has_extern_C); ws::ABIBoundaryNode node; node.name = "send_request"; node.kind = "function"; node.fromComponent = "http-server"; node.toComponent = "api-client"; node.fromLanguage = "Go"; node.toLanguage = "C++"; node.signature = {{"name","send_request"},{"kind","function"},{"exported",true}, {"returnType","int"},{"params",json::array()}}; std::string header = ws::CHeaderEmitter::emit({node}, "poly_api"); C(header.find("extern \"C\"") != std::string::npos, "C header must have extern C block"); C(header.find("send_request") != std::string::npos, "C header must contain send_request"); C(header.find("#ifndef") != std::string::npos, "C header must have include guard"); P(); } void t4(){ T(dwarf_annotation_has_DW_TAG_subprogram_for_function); ws::ABIBoundaryNode node; node.name = "send_request"; node.kind = "function"; node.fromComponent = "http-server"; node.toComponent = "api-client"; node.fromLanguage = "Go"; node.toLanguage = "C++"; node.signature = {{"name","send_request"},{"kind","function"},{"exported",true}}; auto annotations = ws::DWARFBoundaryAnnotator::annotate({node}); C(!annotations.empty(), "must have at least one annotation"); C(annotations[0]["dwarfTag"] == "DW_TAG_subprogram", "function boundary must have DW_TAG_subprogram"); C(annotations[0]["crossLangBoundary"] == true, "must flag crossLangBoundary=true"); P(); } void t5(){ T(sprint274_integration_summary_correct); ws::Sprint274IntegrationSummary s; C(s.stepsCompleted == 5, "expected 5 steps"); C(s.bindingPairsImplemented == 4, "expected 4 binding pairs (RustPython, GoCpp, RustGo, CppJS)"); C(s.mcpToolsAdded == 1, "expected 1 new MCP tool (whetstone_generate_ffi_glue)"); C(s.success, "success must be true"); C(s.sprintName() == "Sprint 274: More Binding Pairs + DWARF Annotations", "sprintName mismatch: " + s.sprintName()); P(); } int main(){ std::cout << "Step 1902: Sprint 274 Integration\n"; t1(); t2(); t3(); t4(); t5(); std::cout << "\n" << p << "/" << (p+f) << " passed\n"; return f > 0 ? 1 : 0; }