Fflua Update-adds reference support and fflua update adds reference

Source: Internet
Author: User

Fflua Update-adds reference support and fflua update adds reference
Introduction:

Fflua has been released for a while, and many netizens have used it and provided some good feedback. One of them is the support for reference when the c ++ interface is registered to lua. This makes it easier to use.

Original method:

Use the following method to register c ++ classes in fflua:

Class base_t {public: base_t (): v (789) {} void dump () {printf ("in % s a: % d \ n", _ FUNCTION __, v) ;}int v ;};//! Register a base-class function. ctor () is the type of the constructor fflua_register_t <base_t, ctor ()> (ls, "base_t ")//! Register the constructor. def (& base_t: dump, "dump ")//! Register the function of the base class. def (& base_t: v, "v ");//! Register the attributes of a base class

After the c ++ class is successfully registered, the lua code can operate the Class Object Pointer and pass it as a parameter to the c ++ interface:

Void dumy_base (base_t * p) {printf ("in % s begin ------------ \ n", _ FUNCTION _);} fflua_register_t <> (ls ). def (& dumy, "dumy ");//! Register static functions

Some netizens told me that many of the original interfaces use references as parameters. In order to receive the parameters passed by lua, you have to write a new function, which is troublesome, therefore, fflua adds reference support:

Void dumy_base (base_t & p) {printf ("in % s begin ------------ \ n", _ FUNCTION _);} fflua_register_t <> (ls ). def (& dumy, "dumy ");//! Register static functions

 

Summary:

Latest code:

Https://github.com/fanchy/fflua

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.