Giter Club home page Giter Club logo

Comments (2)

IS4Code avatar IS4Code commented on August 26, 2024 1

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.

IS4Code avatar IS4Code commented on August 26, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.