mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-21 12:00:18 +00:00
Merge branch 'main' of https://github.com/blueloveTH/pocketpy
This commit is contained in:
commit
e0c057191a
6
.github/workflows/main.yml
vendored
6
.github/workflows/main.yml
vendored
@ -68,6 +68,10 @@ jobs:
|
|||||||
runs-on: macos-latest
|
runs-on: macos-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
- name: Compile and Test
|
||||||
|
run: |
|
||||||
|
bash build.sh
|
||||||
|
python3 scripts/run_tests.py
|
||||||
- run: |
|
- run: |
|
||||||
python3 amalgamate.py
|
python3 amalgamate.py
|
||||||
cd plugins/macos/pocketpy
|
cd plugins/macos/pocketpy
|
||||||
@ -107,4 +111,4 @@ jobs:
|
|||||||
rm -rf tmp
|
rm -rf tmp
|
||||||
- uses: actions/upload-artifact@v3
|
- uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
path: plugins/flutter/example/build/app/outputs/flutter-apk/output
|
path: plugins/flutter/example/build/app/outputs/flutter-apk/output
|
||||||
|
@ -21,6 +21,13 @@ if(MSVC)
|
|||||||
add_compile_options("/utf-8")
|
add_compile_options("/utf-8")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(NOT CMAKE_BUILD_TYPE)
|
||||||
|
set(CMAKE_BUILD_TYPE Release)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(CMAKE_CXX_FLAGS_DEBUG "-g")
|
||||||
|
set(CMAKE_CXX_FLAGS_RELEASE "-O2")
|
||||||
|
|
||||||
include_directories(${CMAKE_CURRENT_LIST_DIR}/include)
|
include_directories(${CMAKE_CURRENT_LIST_DIR}/include)
|
||||||
|
|
||||||
aux_source_directory(${CMAKE_CURRENT_LIST_DIR}/src POCKETPY_SRC)
|
aux_source_directory(${CMAKE_CURRENT_LIST_DIR}/src POCKETPY_SRC)
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "vm.h"
|
#include "vm.h"
|
||||||
|
#include "_generated.h"
|
||||||
|
|
||||||
namespace pkpy {
|
namespace pkpy {
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
#include <variant>
|
#include <variant>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
||||||
#define PK_VERSION "1.1.0"
|
#define PK_VERSION "1.1.1"
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "export.h"
|
#include "export.h"
|
||||||
|
@ -9,7 +9,6 @@
|
|||||||
#include "linalg.h"
|
#include "linalg.h"
|
||||||
#include "easing.h"
|
#include "easing.h"
|
||||||
#include "io.h"
|
#include "io.h"
|
||||||
#include "_generated.h"
|
|
||||||
#include "vm.h"
|
#include "vm.h"
|
||||||
#include "re.h"
|
#include "re.h"
|
||||||
#include "random.h"
|
#include "random.h"
|
||||||
|
@ -115,11 +115,10 @@ struct StrName {
|
|||||||
return this->index > other.index;
|
return this->index > other.index;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline static std::map<Str, uint16_t, std::less<>> _interned;
|
|
||||||
inline static std::vector<Str> _r_interned;
|
|
||||||
|
|
||||||
static bool is_valid(int index);
|
static bool is_valid(int index);
|
||||||
static StrName get(std::string_view s);
|
static StrName get(std::string_view s);
|
||||||
|
static std::map<std::string, uint16_t, std::less<>>& _interned();
|
||||||
|
static std::vector<std::string>& _r_interned();
|
||||||
};
|
};
|
||||||
|
|
||||||
struct FastStrStream{
|
struct FastStrStream{
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
#if PK_MODULE_RANDOM
|
#if PK_MODULE_RANDOM
|
||||||
|
|
||||||
#include <random>
|
#include <random>
|
||||||
#include "pocketpy/_generated.h"
|
|
||||||
|
|
||||||
namespace pkpy{
|
namespace pkpy{
|
||||||
|
|
||||||
|
32
src/str.cpp
32
src/str.cpp
@ -312,22 +312,33 @@ int utf8len(unsigned char c, bool suppress){
|
|||||||
return os << sn.sv();
|
return os << sn.sv();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::map<std::string, uint16_t, std::less<>>& StrName::_interned(){
|
||||||
|
static std::map<std::string, uint16_t, std::less<>> interned;
|
||||||
|
return interned;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string>& StrName::_r_interned(){
|
||||||
|
static std::vector<std::string> r_interned;
|
||||||
|
return r_interned;
|
||||||
|
}
|
||||||
|
|
||||||
StrName StrName::get(std::string_view s){
|
StrName StrName::get(std::string_view s){
|
||||||
auto it = _interned.find(s);
|
auto it = _interned().find(s);
|
||||||
if(it != _interned.end()) return StrName(it->second);
|
if(it != _interned().end()) return StrName(it->second);
|
||||||
uint16_t index = (uint16_t)(_r_interned.size() + 1);
|
uint16_t index = (uint16_t)(_r_interned().size() + 1);
|
||||||
_interned[s] = index;
|
std::string str(s);
|
||||||
_r_interned.push_back(s);
|
_interned()[str] = index;
|
||||||
|
_r_interned().push_back(str);
|
||||||
return StrName(index);
|
return StrName(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
Str StrName::escape() const {
|
Str StrName::escape() const {
|
||||||
return _r_interned[index-1].escape();
|
return Str(sv()).escape();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StrName::is_valid(int index) {
|
bool StrName::is_valid(int index) {
|
||||||
// check _r_interned[index-1] is valid
|
// check _r_interned()[index-1] is valid
|
||||||
return index > 0 && index <= _r_interned.size();
|
return index > 0 && index <= _r_interned().size();
|
||||||
}
|
}
|
||||||
|
|
||||||
StrName::StrName(): index(0) {}
|
StrName::StrName(): index(0) {}
|
||||||
@ -337,7 +348,10 @@ int utf8len(unsigned char c, bool suppress){
|
|||||||
index = get(s.sv()).index;
|
index = get(s.sv()).index;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string_view StrName::sv() const { return _r_interned[index-1].sv(); }
|
std::string_view StrName::sv() const {
|
||||||
|
const std::string& str = _r_interned()[index-1];
|
||||||
|
return std::string_view(str);
|
||||||
|
}
|
||||||
|
|
||||||
FastStrStream& FastStrStream::operator<<(const Str& s){
|
FastStrStream& FastStrStream::operator<<(const Str& s){
|
||||||
parts.push_back(&s);
|
parts.push_back(&s);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user