Comments (2)
Coincidentally, I was thinking about this yesterday. The goal is to first separate the current format specifiers used by str_format
and make them handled by a corresponding tag function for every tag, then link the specifiers back to the tags (with multiple specifiers linking to a single tag, like d
and x
) and allow other specifiers to be added. tag_op_string
would be changed to tag_op_format
and would receive the additional format parameters, if any (as a string).
The basis for this was already outlined in 5104426, but a lot of work still needs to be done.
from pawnplus.
@AGraber
Implemented in 12cd765 and newer commits.
A specifier like %d
is now decomposed into two actions: find the tag that corresponds to the selector (cell) and let that tag handle the format.
The first part is configurable via str_register_format
which allows modifying the internal table and changing what the letters correspond to, or adding new ones.
The actual format operation is handled by tag_op_format
(and tag_op_string
as a fallback). The signature of the handler is as follows:
forward String:handler(value, type, String:format);
Due to the limitations of the inner workings (and also the fact that tag operations can be also assigned from the underutilized C API and now also to expressions), only a single cell value can be passed to the handler. However, with the is_string
parameter of str_register_format
, a string can be automatically converted to String:
.
What remains are two "unconfigurable" cases: the %P
specifier which depends on the AMX instance and thus cannot be handled by any tag, and the sole case of a single "%s"
format string which is optimized to skip this whole tag lookup due to its frequent use. However, both of these and also non-letters are allowed in str_register_format
.
The format
operation can be also called manually (expecting the same layout of arguments as the handler) or from str_val
.
It's funny that this took me two years of waiting and two days of actual programming.
from pawnplus.
Related Issues (20)
- Including PawnPlus crashes Compiler HOT 2
- Question about list_find
- map_clear_deep removes reference HOT 1
- I have a question HOT 4
- Linux crash HOT 11
- Server crashes at Ubuntu 20.04 HOT 13
- Crash using str_format in MySQL functions HOT 1
- Backward Compatibility HOT 9
- Crash HOT 1
- Run time error 10: "Native function failed" HOT 3
- Constant Iterators HOT 3
- How did you create a custom locale? HOT 2
- Incompatible with log-core HOT 1
- Errorduring compilation HOT 10
- List of tasks as a parameter in `task_all` HOT 6
- task_detach crash with JIT HOT 1
- Crash Ubuntu HOT 6
- Crash Ubuntu Ubuntu 20.04.6 LTS HOT 1
- argument 'index' is out of range HOT 3
- help please HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pawnplus.