Commit graph

77 commits

Author SHA1 Message Date
turleypol
17911b23aa
impptr_if method/impptrIf function to test and return Imp derived classes (#685)
* impptr_if method/impptrIf function to test and return Imp derived
classes.
Simplified a few spots

* more usage of impptr

* fix makeDouble

* fix warnings

* more warnings

* more warnings..

* replaced new/remaining casts

* non owning imp* needs to be protected

* silly me
2024-08-07 22:14:52 +02:00
turleypol
cf0c730181
switched impptr to template with default type (#680) 2024-08-03 12:35:01 +02:00
turleypol
cccf84dfc8
Fewer compile warnings (#413)
* added escriptgrammar as external lib where it belongs. Silenced warnings.

* bscript compiler warning fixes

* special include file to get rid of gcc warnings about antlr4

* misc windows warnings

* time specifc warnings

* buildfix + apple warnings

* never trust apple

* windows debug build warnings

* some windows clang warnings

* last warning fix
2021-08-28 22:26:15 +02:00
Kevin Eady
e41f70d72e
Add support for interpolated strings ("interstrings") (#369)
* Update grammar to support interpolated strings

* Struct initializers, case switchs are regular strings

* Initial stub for interpolated string in AST
This splits the previous STRING_LITERAL terminal into a production,
stringLiteral, to handle REGULAR_STRING terminal and interpolatedString
production.

* Change interpolated strings to expressions

* Fix mode handling in grammar

* Grammar fixes
- Fix mode handling in lexer
- Interpolated strings only have one expression

* Can successfully parse, stub compile interstrings
$"He {there + print("hello")}";

* Add formatting string to grammar

* Fix tests, and add test stubs

* Rename curleys to brace; better AST generation

* initial work interstring instruction

* Initial work on formatted string instruction: emit

* Formatted string instruction: execution

* Add simple formatted string test

* Add formatted string test src

* Review changes #1
- Rename `FormattedString` to `FormatExpression`
- Rename overloaded `try_to_format()` to `get_formatted()`

* Review changes part 2
- Rename `InterpolatedString` ast node to `InterpolateString`

* Review changes part 3
- Modify `ins_interpolate_string`

* Review changes part 4
- Remove unused formal parameter

* Add negative tests

* Spruce up positive tests

* Fix braces, escape chars inside interstring

* Fix, add tests for escaped char and double brace

* Address differences for new lines in tests

* Update Escript version

* Make empty expression an error

* Add documentation for interpolated strings

* Quick touchup on docs
2021-03-11 22:48:16 +01:00
turleypol
90b92f4002
Get environment variable/Extended Testsuite (#359)
* added os:GetEnvironmentVariable to list all environs or get a single one

* first version of restarting the core to test save/load
added environment variable to filter tests

* fixed string constructor (size_t instead of signed int)

* added string_view constructor

* splitted and extended restart tests

* added docs

* added pol.cfg setting to disallow environment variable access

* Change environmental variable access rules
Instead of defaulting to all values allowed, now defaults to none. May
specify either `*` to allow all variables, or a comma-delimited list.

* Address review changes
- Use Clib lower instead of boost
- const auto references
- Separate tests for access and finding env vars

* Update documentation

* Apply suggestions from code review

Co-authored-by: Kevin Eady <8634912+KevinEady@users.noreply.github.com>
Co-authored-by: Fernando Rozenblit <rozenblit@gmail.com>
2021-02-27 08:36:22 +01:00
Eric Swanson
2cae8137f3
Enable building on OSX (clion) (#318)
* Build on OSX

* Add macos-latest to build matrix

* Fix case sensitivity checks/tests

* On osx builds, cope with unpacking a double that might be followed by either an exponent or an error (as part of an array).

Also, remove static unpack(const char*) forms that were never called.

Co-authored-by: turleypol <turley@polserver.com>
2020-09-26 06:57:10 -07:00
turleypol
1bdbd5150b
fixed crash in str.format when invalid param index is given (#307) 2020-09-13 11:38:17 +02:00
Kevin Eady
7ad3db992e
move checking of utf-8 chars to both platforms 2020-01-18 00:28:20 +01:00
Kevin Eady
6fe3b2111d windows: add utf8 checks to lower/upper 2020-01-17 20:15:34 +01:00
turleypol
d004f9d2a6 fixed uncaught exeption (which only a static analyser finds and likely never occurs) 2020-01-09 21:43:43 +01:00
turleypol
b450c4a782 optimized a few more things in string class 2019-09-07 15:27:56 +02:00
turleypol
04437fbcd7 optimized windows version of upper/lower a bit 2019-09-07 14:26:39 +02:00
turleypol
6a62981c85 changed getBytePosition param to pointer to clarify usage and
sideeffects.
ConstString no more assumes tainted source, tus file loading now also
sanitizes data.
Removed duplicate usage of isValidUnicode, sanitize methods also test
it.
2019-09-02 21:37:45 +02:00
turleypol
8b085e86ef dont assume a tainted string by default
cfgfiles (which includes savefiles, datafiles) get sanizized on read,
filemod::readfile, xml module, sql handled
old ascii speech packets handled
2019-01-12 17:14:05 +01:00
turleypol
04066c309d moved unicode sanitize functions to clib as a preparation to sanitize
only once
renamed mklower/mkupper to make it clear that it should only be used
for pure ascii texts
compiler triggers only once a warning about invalid unicode file
2019-01-12 11:46:30 +01:00
turleypol
8c7ed986a9 CAsc(Z)/CChr(Z) use utf16, if CChr() cannot represent it with a single
number return an error.
Fixed problem with RequestInput using the unicode version
Updated em file comments
2019-01-04 13:18:53 +01:00
turleypol
f4ae345155 If a unicode string is detected as param sysmsg etc module functions
automatically use the unicode replacement
2019-01-03 22:14:10 +01:00
turleypol
3257cda6ab cleanup of cliloc unicode functions 2019-01-03 17:21:55 +01:00
turleypol
cc27bb611f removed last usage of convertUCtoArray 2019-01-03 11:00:46 +01:00
turleypol
ae56e5063e fixed more warnings 2019-01-03 00:27:01 +01:00
turleypol
55538a2fae added utf8 read method, seems OSI couldnt decide which format they
use...
2019-01-02 13:36:59 +01:00
turleypol
f01f9cf72b convert from utf16 directly handles endianess 2019-01-01 17:33:09 +01:00
turleypol
a6c7a471a1 simplified string api, converted requestinputuc return packet 2019-01-01 15:47:27 +01:00
turleypol
ab89708107 completly converted all uses of convertArrayToUC, so all
functions/methods now accept arrays and strings
2018-12-31 16:25:34 +01:00
turleypol
366f7e7122 Merge remote-tracking branch 'upstream/master'
* upstream/master: (45 commits)
  renamed mobile syshook to character used unique_ptr for all syshooks
  added docs
  code simplification, deprecate warning for uoclient.cfg MethodScript entry
  party and guild ref support docs and testing left?
  custom methods for client and account references
  fixed line length
  syshooks for npc/mobiles
  first round for scripted object class methods
  Fixed formatting error.
  Added new return option to consume ammunition hook which allows the hook to make the core continue with the usual ammunition checks.
  Fix critical bug in FindObjtypeInContainer()
  fixed compiler warning
  fixed linesize
  windows fixes
  Added cmake option to run clang-tidy used everywhere nullptr
  Changed classes to be final if possible, removed override macro
  Added additional documentation.
  next..
  clang 7 is currently untrusted... next try 6 ;)
  fixed new clang warnings, new compiler version on travis (lets see how many commits are needed till it works)
  ...

Conflicts:
	.travis.yml
	pol-core/bscript/impstr.h
	pol-core/clib/cfgfile.cpp
	pol-core/pol/module/npcmod.cpp
2018-10-14 14:00:33 +02:00
turleypol
a5e6206164 Added cmake option to run clang-tidy
used everywhere nullptr
2018-10-09 16:36:35 +02:00
turleypol
ee10d76ec4 started with unimod 2018-06-25 19:31:01 +02:00
turleypol
72889beabf part II 2018-06-25 19:31:00 +02:00
turleypol
ecbe6ab4b9 silence I kill you 2018-06-25 19:31:00 +02:00
turleypol
e22f037979 invalid utf8 will be assumed to be iso8859 (with the hope that this is
correct in most of the cases)
2018-06-25 19:31:00 +02:00
turleypol
2ea0a7bb55 runecl no more tries to log to pol files
sanitize strings on construction (if external)
use faster unsafe utf methods
2018-06-25 19:31:00 +02:00
turleypol
ad695899dd optimized memoryallocations if resulting string after conversion has
the same size.
2018-06-25 19:31:00 +02:00
turleypol
940693bde1 no extra null terminator for windows case convertion 2018-06-25 19:31:00 +02:00
turleypol
f668e4876d try to fix windows upper/lower case conversion 2018-06-25 19:31:00 +02:00
turleypol
6e50fcd7a2 sanitize strings during compilation
shameless copy of bodoms unicode test plus a few additions/modifications
2018-06-25 19:31:00 +02:00
turleypol
a064901a4f use template deduction for different wchar_t sizes 2018-06-25 19:31:00 +02:00
turleypol
c50188b142 fixed a few more functions, cleanup 2018-06-25 19:31:00 +02:00
turleypol
a3cf0e8fef fix windows build 2018-06-25 19:31:00 +02:00
turleypol
431411f9bc lower/uppercase in unicode 2018-06-25 19:31:00 +02:00
turleypol
84afea1bc1 unicode: find and compare 2018-06-25 19:31:00 +02:00
turleypol
890f803a20 removed some unused methods 2018-06-25 19:31:00 +02:00
turleypol
bc78a3a349 fixed strreplace, substr
made some constructors private
2018-06-25 19:30:59 +02:00
turleypol
f3d92ad172 more utf8 support 2018-06-25 19:30:59 +02:00
turleypol
af5d3f38d7 utf8 work in progress 2018-06-25 19:30:59 +02:00
turleypol
239295f236 added options to enable clang/gcc sanitizer
fixed a few errors in runecl/ecompile code
2018-04-26 10:42:19 +02:00
turleypol
dbb25bdb62
Include and buildsystem cleanup (#45)
Include cleanup
Reworked buildsystem (Linux only)
Removed dynamic libs, Linux now again uses static linking (like windows)
2018-01-29 21:55:48 +01:00
turleypol
ef2108c9f7 New objecttype Boolean.
create via basic::Boolean(1/0)
only == != ! operators are implemented.
2018-01-05 20:04:01 +01:00
turley
65231f9bfd use faster overload for string find with single characters 2016-12-15 13:34:06 +01:00
turley
feb77cb02c restoring stream format state 2016-12-09 20:21:42 +01:00
turley
189cad3479 Formating everything
Authors are not forced to use the clang-format setting, but should
atleast be inspired by the style.
The only thing which is now not allowed are tabs for ident/alignment!
2016-02-19 19:26:35 +01:00