Skip to content

Commit

Permalink
feat: unlimited implementation for meter attribute getter
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmad-kemsan committed Jul 30, 2024
1 parent e306f70 commit 0d5fbdb
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
20 changes: 10 additions & 10 deletions src/lexfloatclient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@ import { LexFloatStatusCodes } from "./lexfloatstatus-codes";
export class HostLicenseMeterAttribute {
/** The name of the meter attribute. */
name: string;
/** The allowed uses of the meter attribute. */
allowedUses: number;
/** The allowed uses of the meter attribute. A value of -1 indicates unlimited allowed uses. */
allowedUses: bigint;
/** The total uses of the meter attribute. */
totalUses: number;
totalUses: bigint;
/** The gross uses of the meter attribute. */
grossUses: number;
grossUses: bigint;
/**
* @param name The name of the meter attribute.
* @param allowedUses The allowed uses of the meter attribute.
* @param allowedUses The allowed uses of the meter attribute. A value of -1 indicates unlimited allowed uses.
* @param totalUses The total uses of the meter attribute.
* @param grossUses The gross uses of the meter attribute.
*/
constructor(name: string, allowedUses: number, totalUses: number, grossUses: number) {
constructor(name: string, allowedUses: bigint, totalUses: bigint, grossUses: bigint) {
this.name = name;
this.allowedUses = allowedUses;
this.totalUses = totalUses;
Expand Down Expand Up @@ -200,13 +200,13 @@ export class LexFloatClient {
* @throws {LexFloatClientException}
*/
static GetHostLicenseMeterAttribute(name: string): HostLicenseMeterAttribute {
const allowedUses = new Uint32Array(1);
const totalUses = new Uint32Array(1);
const grossUses = new Uint32Array(1);
const allowedUses = new BigInt64Array(1);
const totalUses = new BigUint64Array(1);
const grossUses = new BigUint64Array(1);
const status = LexFloatClientNative.GetHostLicenseMeterAttribute(name, allowedUses, totalUses, grossUses);
switch (status) {
case LexFloatStatusCodes.LF_OK:
return new HostLicenseMeterAttribute(name, allowedUses[0] ? allowedUses[0] : 0, totalUses[0] ? totalUses[0] : 0, grossUses[0] ? grossUses[0] : 0);
return new HostLicenseMeterAttribute(name, allowedUses[0] ? allowedUses[0] : BigInt(0), totalUses[0] ? totalUses[0] : BigInt(0), grossUses[0] ? grossUses[0] : BigInt(0));
default:
throw new LexFloatClientException(status);
}
Expand Down
4 changes: 2 additions & 2 deletions src/native/LexFloatClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,13 +187,13 @@ LEXFLOATCLIENT_API int LF_CC GetHostLicenseMetadata(CSTRTYPE key, STRTYPE value,
PARAMETERS:
* name - name of the meter attribute
* allowedUses - pointer to the integer that receives the value
* allowedUses - pointer to the integer that receives the value. A value of -1 indicates unlimited allowed uses.
* totalUses - pointer to the integer that receives the value
* grossUses - pointer to the integer that receives the value
RETURN CODES: LF_OK, LF_E_PRODUCT_ID, LF_E_NO_LICENSE, LF_E_METER_ATTRIBUTE_NOT_FOUND
*/
LEXFLOATCLIENT_API int LF_CC GetHostLicenseMeterAttribute(CSTRTYPE name, uint32_t *allowedUses, uint32_t *totalUses, uint32_t *grossUses = NULL);
LEXFLOATCLIENT_API int LF_CC GetHostLicenseMeterAttribute(CSTRTYPE name, int64_t *allowedUses, uint64_t *totalUses, uint64_t *grossUses = NULL);

/*
FUNCTION: GetHostLicenseExpiryDate()
Expand Down
12 changes: 6 additions & 6 deletions src/native/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,12 +245,12 @@ Napi::Value getHostLicenseMeterAttribute(const Napi::CallbackInfo &info)
return env.Null();
}
STRING arg0 = toEncodedString(info[0].As<Napi::String>());
Napi::Uint32Array array1 = info[1].As<Napi::Uint32Array>();
uint32_t *arg1 = reinterpret_cast<uint32_t *>(array1.ArrayBuffer().Data());
Napi::Uint32Array array2 = info[2].As<Napi::Uint32Array>();
uint32_t *arg2 = reinterpret_cast<uint32_t *>(array2.ArrayBuffer().Data());
Napi::Uint32Array array3 = info[3].As<Napi::Uint32Array>();
uint32_t *arg3 = reinterpret_cast<uint32_t *>(array3.ArrayBuffer().Data());
Napi::BigInt64Array array1 = info[1].As<Napi::BigInt64Array>();
uint32_t *arg1 = reinterpret_cast<int64_t *>(array1.ArrayBuffer().Data());
Napi::BigInt64Array array2 = info[2].As<Napi::BigInt64Array>();
uint32_t *arg2 = reinterpret_cast<uint64_t *>(array2.ArrayBuffer().Data());
Napi::BigInt64Array array3 = info[3].As<Napi::BigInt64Array>();
uint32_t *arg3 = reinterpret_cast<uint64_t *>(array3.ArrayBuffer().Data());
return Napi::Number::New(env, GetHostLicenseMeterAttribute(arg0.c_str(), arg1, arg2, arg3));
}

Expand Down

0 comments on commit 0d5fbdb

Please sign in to comment.