Skip to content

Commit

Permalink
Add client_transparent attribute to String constructors
Browse files Browse the repository at this point in the history
  • Loading branch information
DutChen18 committed Sep 2, 2024
1 parent 05458bc commit f9035ae
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/extensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,12 @@ function addExtern(parser: Parser, name: string) {

// Utility function, adds a conversion constructor to `classObj` to convert
// from the type `type`.
function addConversionConstructor(classObj: Class, type: Type): void {
function addConversionConstructor(classObj: Class, type: Type): Function {
const funcObj = new Function(classObj.getName());
funcObj.addFlags(Flags.Noexcept);
funcObj.addParameter(type, "x");
classObj.addMember(funcObj, Visibility.Public);
return funcObj;
}

// Utility function, adds a conversion constructor to `classObj` to convert
Expand All @@ -61,14 +62,17 @@ function addObjectInitializerConstructor(classObj: Class, type: Type): Function
function addStringExtensions(parser: Parser, stringClass: Class): void {
const stringType = DeclaredType.create(stringClass);

addConversionConstructor(stringClass, stringType.constPointer());
addConversionConstructor(stringClass, stringType.constReference());
const stringPointerConstructor = addConversionConstructor(stringClass, stringType.constPointer());
const stringReferenceConstructor = addConversionConstructor(stringClass, stringType.constReference());
addConversionConstructor(stringClass, LONG_TYPE);
addConversionConstructor(stringClass, UNSIGNED_LONG_TYPE);
addConversionConstructor(stringClass, INT_TYPE);
addConversionConstructor(stringClass, UNSIGNED_INT_TYPE);
addConversionConstructor(stringClass, DOUBLE_TYPE);

stringPointerConstructor.addAttribute("cheerp::client_transparent");
stringReferenceConstructor.addAttribute("cheerp::client_transparent");

const fromUtf8 = new Function("fromUtf8", stringType.pointer());
fromUtf8.addAttribute("gnu::always_inline");
fromUtf8.addFlags(Flags.Static);
Expand Down

0 comments on commit f9035ae

Please sign in to comment.