{"id":15047180,"url":"https://github.com/johnsonyl/cpps","last_synced_at":"2025-06-22T02:36:08.597Z","repository":{"id":199235620,"uuid":"78904641","full_name":"johnsonyl/cpps","owner":"johnsonyl","description":"CPPS is a lightweight embedded scripting language with syntax similar to C++. It has many features of the current mainstream languages, including coroutine, object-oriented, lambda, closure, generic variable, custom module support, GC garbage collection and cross platform. CPPS interprets the program as bytecode to run in virtual machine through built-in syntax parsing","archived":false,"fork":false,"pushed_at":"2024-11-27T15:11:28.000Z","size":76831,"stargazers_count":32,"open_issues_count":0,"forks_count":8,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-06-09T16:03:52.978Z","etag":null,"topics":["c-plus-plus","cpp","cpps","cppscript","embedded-scripting-language","script"],"latest_commit_sha":null,"homepage":"http://cppscript.org","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/johnsonyl.png","metadata":{"files":{"readme":"README.md","changelog":"changelog.md","contributing":null,"funding":null,"license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-01-14T02:20:37.000Z","updated_at":"2024-11-27T15:21:17.000Z","dependencies_parsed_at":null,"dependency_job_id":"b8d9ee3d-9260-4d62-8230-05a68c9535c9","html_url":"https://github.com/johnsonyl/cpps","commit_stats":null,"previous_names":["johnsonyl/cpps"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/johnsonyl/cpps","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnsonyl%2Fcpps","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnsonyl%2Fcpps/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnsonyl%2Fcpps/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnsonyl%2Fcpps/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/johnsonyl","download_url":"https://codeload.github.com/johnsonyl/cpps/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnsonyl%2Fcpps/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261225647,"owners_count":23127178,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c-plus-plus","cpp","cpps","cppscript","embedded-scripting-language","script"],"created_at":"2024-09-24T20:55:06.436Z","updated_at":"2025-06-22T02:36:03.587Z","avatar_url":"https://github.com/johnsonyl.png","language":"C++","readme":"# cppscript\r\n#### **Welcome**\r\n\r\nCPPS is a powerful, fast, and easy-to-use interpreted scripting language. It is very easy to learn and use, and can be easily embedded into C++ projects.\r\n\r\nCPPS was originally designed to be used by developers who like the author don't like LUA, Python syntax. It can be connected to various projects, whether it is Games, Web, or AI.\r\n\r\nIts syntax is very similar to C++, so C++ developers can get started quickly without having to learn it in depth.\r\n\r\n*Recruiting collaborative software authors and third-party module authors.*\r\n\r\n#### **Download and Compile**\r\n\r\nThe download and installation of CPPS is very simple. CPPS does not depend on any third-party libraries and can be compiled by just downloading it.\r\n\r\n*LINUX \u0026 MACOS*:\r\n-\r\n```\r\ngit clone https://github.com/johnsonyl/cpps.git\r\n\r\ncmake .\r\n\r\nmake\r\n\r\nmake install\r\n\r\n;Whether to compile extension modules as needed.\r\ncpps buildlibs\r\n\r\n```\r\n*Windows*\r\n-\r\n```\r\ngit clone https://github.com/johnsonyl/cpps.git\r\n\r\ncmake .\r\n\r\nUse Visual Studio to open libcpps.sln and compile it.\r\n\r\ncd libs\r\n\r\n;Whether to compile extension modules as needed.\r\n\r\ncmake.\r\n\r\nUse Visual Studio to open cppslibs.sln and compile it.\r\n\r\n```\r\n\r\nIsn't it very simple?\r\n\r\nThe libs folder is an internal extension module. Please check the documentation for specific compilation rules.\r\n\r\n[Change log](changelog.md) Last updated date: 2021-03-06 23:52:00 Beijing/cn\r\n\r\nThe script documentation is at\r\n\r\nhttp://docs.cppscript.org\r\n\r\nQQ group:\r\n\r\nCPPS script communication group: 282081601\r\n\r\nAuthor QQ: 88481106\r\n\r\n\r\nExample:\r\n-\r\n\r\nHello World:\r\n-\r\n\r\n```\r\nprintln(\"hello world\");\r\n```\r\n\r\nbase64:\r\n-\r\n\r\n```\r\n#import \"base64\"\r\n\r\n\r\nvar s = \"abc\";\r\nprintln(\"source:{s}\");\r\nvar encode_s = base64.encode(s);\r\nprintln(\"encode_s:{encode_s}\");\r\nvar deocde_s = base64.decode(encode_s);\r\nprintln(\"deocde_s:{deocde_s}\");\r\n```\r\n\r\n\r\nasyncio:\r\n-\r\n\r\n```\r\n\r\nasync var test()\r\n{\r\n\tprintln(\"do test function\");\r\n\tawait asyncio.wait_for(asyncio.sleep(2000),100);\r\n\tprintln(\"do test function done\");\r\n\treturn \"test\";\r\n\r\n}\r\nasync var test1()\r\n{\r\n\tprintln(\"do test1 function\");\r\n\tawait asyncio.sleep(1000);\r\n\tprintln(\"do test1 function done\");\r\n\t\r\n\treturn \"test1\";\r\n}\r\nvar test_call_back(var task, var context)\r\n{\r\n\tprintln(task.get_name());\r\n\tprintln(context);\r\n}\r\n\r\nasync var main() {\r\n\r\n\tvar task1 = asyncio.create_task(test());\r\n\ttask1.set_name(\"Custom names are used to distinguish\");\r\n\ttask1.add_done_callback(test_call_back, \"Custom context content\");\r\n\tvar task2 = asyncio.create_task(test1());\r\n\r\n\tvar ret = await asyncio.wait(task1);\r\n\tif (ret.timeout())\r\n\t{\r\n\t\tprintln(\"task1 was timeouted.\");\r\n\t}\r\n\tprintln(\"state:{ret.state()}\");\r\n\tprintln(ret.result());\r\n\ttry {\r\n\t\tprintln(await task2);\r\n\t}\r\n\tcatch (var e)\r\n\t{\r\n\t\tprintln(\"oh,we catch some error\");\r\n\t\tprintln(\"{e.what()} line:{e.line()} file:{e.file()}\");\r\n\t\tprintln(e.callstack());\r\n\t}\r\n\r\n\tprintln(\"finish\");\r\n}\r\n\r\nasyncio.run(main());\r\n\r\n```\r\n\r\nsocket - server:\r\n-\r\n\r\n```\r\nsystem(\"chcp 65001\"); //use utf8 string\r\n\r\n#import \"socket\"\r\n\r\n\r\n\r\n\r\n//server\r\nvar socket_accept(var socketIndex)\r\n{\r\n\tprintln(\"acceptd:{socketIndex}\");\r\n}\r\nvar socket_data(var socketIndex,var buffer) \r\n{\r\n\tvar packageSize = buffer.readInt32();\r\n\r\n\tvar s = buffer.readString(packageSize-4);\r\n\tprintln(s);\r\n\r\n\tif(s == \"e\")\r\n\t{\r\n\t\tsrv.closesocket(socketIndex);\r\n\t}\r\n\t\r\n\tvar writer = new Buffer();\r\n\twriter.writeString(s);\r\n\tsocket_send(socketIndex, writer);\r\n}\r\nvar socket_close(var socketIndex,var err,var errstr) \r\n{\r\n\tprintln(\"closed :{socketIndex},err:{err},errstr:{errstr}\");\r\n}\r\nvar socket_parser(var headerbuffer)\r\n{\r\n\tvar size = headerbuffer.readInt32();\r\n\treturn size;\r\n}\r\nvar socket_send(var socketIndex,var buffer)\r\n{\r\n\tvar writer = new Buffer();\r\n\twriter.writeInt32(buffer.length() + 4);\r\n\twriter.write(buffer,buffer.length());\r\n\tsrv.send(socketIndex, writer);\r\n}\r\n\r\nprintln(\"start server\");\r\n\r\n\r\nvar srv = new socket::server().setoption(new ServerOption(){\r\n\t\t\t\t\t\t\tip = \"0.0.0.0\",\r\n\t\t\t\t\t\t\theadersize = 4,//header 4 bytes\r\n\t\t\t\t\t\t\taccept = socket_accept,\r\n\t\t\t\t\t\t\tdata = socket_data,\r\n\t\t\t\t\t\t\tclose = socket_close,\r\n\t\t\t\t\t\t\tparser = socket_parser\r\n\t\t\t\t\t\t\t}).listen(4060);\r\n\r\nprintln(\"start over\");\r\nwhile (true){\r\n\tsrv.run();\r\n\tSleep(1);\r\n}\r\n\r\n```\r\n\r\nclient:\r\n-\r\n\r\n```\r\nsystem(\"chcp 65001\"); //use utf8 string\r\n\r\n#import \"socket\"\r\n\r\n\r\n//client\r\nvar socket_connected()\r\n{\r\n\tprintln(\"connected\");\r\n\r\n\tvar writer = new Buffer();\r\n\twriter.writeString(\"this is a pingpong msg\");\r\n\tsocket_send(writer);\r\n}\r\nvar socket_data(var buffer)\r\n{\r\n\tvar packageSize = buffer.readInt32();\r\n\tvar s = buffer.readString(packageSize-4);\r\n\tprintln(s);\r\n\r\n\tSleep(100);\r\n\r\n\t\r\n\tvar writer = new Buffer();\r\n\twriter.writeString(s);\r\n\tsocket_send(writer);\r\n}\r\nvar socket_close(var err,var errstr)\r\n{\r\n\tprintln(\"closed:err:{err},errstr:{errstr}\");\r\n}\r\nvar socket_parser(var headerbuffer)\r\n{\r\n\tvar size = headerbuffer.readInt32();\r\n\treturn size;\r\n}\r\nvar socket_send(var buffer)\r\n{\r\n\tvar writer = new Buffer();\r\n\tvar size = buffer.length();\r\n\twriter.writeInt32(size + 4);\r\n\twriter.write(buffer,buffer.length());\r\n\tclient.send(writer);\r\n}\r\nvar client = new socket::client();\r\nclient.setoption(new ClientOption(){\r\n\t\t\t\t\t\t\tconnected = socket_connected,\r\n\t\t\t\t\t\t\tdata = socket_data,\r\n\t\t\t\t\t\t\tclose = socket_close\r\n\t\t\t\t\t\t\theadersize = 4,//header 4 bytes\r\n\t\t\t\t\t\t\tparser = socket_parser\r\n\t\t\t\t\t\t\t});\r\n\r\nvar b = client.connect(\"127.0.0.1\",4060);\r\n\r\n\r\n\r\nwhile (true)\r\n{\r\n\t\tclient.run();\r\n\t\tSleep(1);\r\n}\r\n```\r\n\r\nhttprequest:\r\n-\r\n\r\n```\r\nsystem(\"chcp 65001\"); //use utf8 string\r\n\r\n#import \"http\"\r\n\r\nvar request = new http::httprequest();\r\nrequest.setcookiefile(\"cookies.txt\");\r\n//request.setproxy(httpproxy.SOCK5,\"192.168.1.166:25455\");\r\n//request.setproxyaccount(\"johnsonyl\",\"mima\");\r\nrequest.addheaders({User-Agent:\"cppsrequest/1.1.0\"});\r\nvar ret = request.get(\"http://127.0.0.1:8080/Home/test?kkk=100\");\r\n\r\n\r\nprintln(\"-------------------GET-------------------------\");\r\nprintln(\"get:{ret}\");\r\nvar cookies = request.getcookies();\r\nprintln(\"cookies:{cookies}\");\r\n\r\nvar headers = request.getheaders();\r\nprintln(\"headers:{headers}\");\r\n\r\n\r\nprintln(\"-------------------POST-------------------------\");\r\nret = request.post(\"http://127.0.0.1:8080/Home/test\",\"kkk=100\");\r\nprintln(\"post:{ret}\");\r\nvar cookies = request.getcookies();\r\nprintln(\"cookies:{cookies}\");\r\n\r\nvar headers = request.getheaders();\r\nprintln(\"headers:{headers}\");\r\nprintln(\"-------------------END-------------------------\");\r\n```\r\n\r\nSee More Example: [bin/example](bin/example)\r\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohnsonyl%2Fcpps","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjohnsonyl%2Fcpps","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohnsonyl%2Fcpps/lists"}