A fat API exposes nearly all of a C++ object's public attributes and methods to a consuming environment, such as a scripting language, or web client. This can be contrasted with a conventional, or thin API, where the API is defined up front, and the C++ object provides the implementation, most of which is private to the C++ layer. Obviously, reflection is required to expose C++ objects to a consuming layer like this -- this paper explores using the Classdesc system to implement reflection of C++ objects into a JavaScript/TypeScript environment via a RESTservice, and also via a Node.js API module.
翻译:胖API将C++对象几乎所有的公共属性和方法暴露给消费环境,例如脚本语言或Web客户端。这与传统的瘦API形成对比:后者需预先定义API接口,C++对象仅负责实现,且大部分实现细节对C++层保持私有。显然,将C++对象如此暴露给消费层需要反射机制的支持——本文探索了利用Classdesc系统,通过REST服务及Node.js API模块,实现C++对象在JavaScript/TypeScript环境中的反射。