| 794 | } |
| 795 | |
| 796 | TSReturnCode |
| 797 | TSRemapNewInstance(int argc, char *argv[], void **ih, char * /* errbuf ATS_UNUSED */ |
| 798 | , |
| 799 | int /* errbuf_size ATS_UNUSED */) |
| 800 | { |
| 801 | auto *inst = new cripts::Instance(argc, const_cast<const char **>(argv)); |
| 802 | cripts::InstanceContext context(*inst); |
| 803 | bool needs_create_instance = wrap_create_instance(&context, false, CaseArg); |
| 804 | |
| 805 | if (needs_create_instance) { |
| 806 | wrap_create_instance(&context, true, CaseArg); |
| 807 | } |
| 808 | |
| 809 | if (!inst->Failed()) { |
| 810 | std::vector<cripts::Bundle::Error> errors; |
| 811 | |
| 812 | for (auto &bundle : inst->bundles) { |
| 813 | // Collect all the callbacks needed from all bundles, and validate them |
| 814 | if (bundle->Validate(errors)) { |
| 815 | inst->NeedCallback(bundle->Callbacks()); |
| 816 | } |
| 817 | } |
| 818 | |
| 819 | if (!errors.empty()) { |
| 820 | TSError("[Cript: %s] - Failed to validate callbacks for the following bundles:", inst->plugin_debug_tag.c_str()); |
| 821 | |
| 822 | for (auto &err : errors) { |
| 823 | TSError("[Cript: %s] \tIn Bundle %.*s, option %.*s()", inst->plugin_debug_tag.c_str(), |
| 824 | static_cast<int>(err.Bundle().size()), err.Bundle().data(), static_cast<int>(err.Option().size()), |
| 825 | err.Option().data()); |
| 826 | TSError("[Cript: %s] \t\t-> %.*s", inst->plugin_debug_tag.c_str(), static_cast<int>(err.Message().size()), |
| 827 | err.Message().data()); |
| 828 | } |
| 829 | delete inst; |
| 830 | return TS_ERROR; |
| 831 | } |
| 832 | |
| 833 | *ih = static_cast<void *>(inst); |
| 834 | |
| 835 | inst->debug("Created a new instance for Cript = {}", inst->plugin_debug_tag); |
| 836 | inst->debug("The context data size = {}", sizeof(cripts::Context)); |
| 837 | |
| 838 | return TS_SUCCESS; |
| 839 | } else { |
| 840 | delete inst; // Cleanup the instance data, which can't be used now |
| 841 | return TS_ERROR; |
| 842 | } |
| 843 | } |
| 844 | |
| 845 | void |
| 846 | TSRemapDeleteInstance(void *ih) |
nothing calls this directly
no test coverage detected