Skip to content

Commit a70155c

Browse files
committed
forgot
1 parent 59f96ff commit a70155c

2 files changed

Lines changed: 40 additions & 37 deletions

File tree

sdk/runanywhere-commons/include/rac/core/rac_sdk_state.h

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ typedef struct {
7878
*
7979
* @return Handle to the SDK state (never NULL after first call)
8080
*/
81-
rac_sdk_state_handle_t rac_state_get_instance(void);
81+
RAC_API rac_sdk_state_handle_t rac_state_get_instance(void);
8282

8383
// =============================================================================
8484
// Initialization & Lifecycle
@@ -95,29 +95,29 @@ rac_sdk_state_handle_t rac_state_get_instance(void);
9595
* @param device_id The persistent device ID (copied internally)
9696
* @return RAC_SUCCESS on success
9797
*/
98-
rac_result_t rac_state_initialize(rac_environment_t env, const char* api_key, const char* base_url,
99-
const char* device_id);
98+
RAC_API rac_result_t rac_state_initialize(rac_environment_t env, const char* api_key,
99+
const char* base_url, const char* device_id);
100100

101101
/**
102102
* @brief Check if SDK state is initialized
103103
* @return true if initialized
104104
*/
105-
bool rac_state_is_initialized(void);
105+
RAC_API bool rac_state_is_initialized(void);
106106

107107
/**
108108
* @brief Reset all state (for testing or re-initialization)
109109
*
110110
* Clears all state including auth tokens, handles, etc.
111111
* Does NOT free the singleton - just resets to initial state.
112112
*/
113-
void rac_state_reset(void);
113+
RAC_API void rac_state_reset(void);
114114

115115
/**
116116
* @brief Shutdown and free all resources
117117
*
118118
* Called during SDK shutdown. Frees all memory and destroys handles.
119119
*/
120-
void rac_state_shutdown(void);
120+
RAC_API void rac_state_shutdown(void);
121121

122122
// =============================================================================
123123
// Environment Queries
@@ -127,25 +127,25 @@ void rac_state_shutdown(void);
127127
* @brief Get current environment
128128
* @return The SDK environment
129129
*/
130-
rac_environment_t rac_state_get_environment(void);
130+
RAC_API rac_environment_t rac_state_get_environment(void);
131131

132132
/**
133133
* @brief Get base URL
134134
* @return The base URL string (do not free)
135135
*/
136-
const char* rac_state_get_base_url(void);
136+
RAC_API const char* rac_state_get_base_url(void);
137137

138138
/**
139139
* @brief Get API key
140140
* @return The API key string (do not free)
141141
*/
142-
const char* rac_state_get_api_key(void);
142+
RAC_API const char* rac_state_get_api_key(void);
143143

144144
/**
145145
* @brief Get device ID
146146
* @return The device ID string (do not free)
147147
*/
148-
const char* rac_state_get_device_id(void);
148+
RAC_API const char* rac_state_get_device_id(void);
149149

150150
// =============================================================================
151151
// Auth State Management
@@ -160,25 +160,25 @@ const char* rac_state_get_device_id(void);
160160
* @param auth The auth data to set
161161
* @return RAC_SUCCESS on success
162162
*/
163-
rac_result_t rac_state_set_auth(const rac_auth_data_t* auth);
163+
RAC_API rac_result_t rac_state_set_auth(const rac_auth_data_t* auth);
164164

165165
/**
166166
* @brief Get current access token
167167
* @return Access token string or NULL if not authenticated (do not free)
168168
*/
169-
const char* rac_state_get_access_token(void);
169+
RAC_API const char* rac_state_get_access_token(void);
170170

171171
/**
172172
* @brief Get current refresh token
173173
* @return Refresh token string or NULL (do not free)
174174
*/
175-
const char* rac_state_get_refresh_token(void);
175+
RAC_API const char* rac_state_get_refresh_token(void);
176176

177177
/**
178178
* @brief Check if currently authenticated
179179
* @return true if authenticated with valid (non-expired) token
180180
*/
181-
bool rac_state_is_authenticated(void);
181+
RAC_API bool rac_state_is_authenticated(void);
182182

183183
/**
184184
* @brief Check if token needs refresh
@@ -187,32 +187,32 @@ bool rac_state_is_authenticated(void);
187187
*
188188
* @return true if refresh is needed
189189
*/
190-
bool rac_state_token_needs_refresh(void);
190+
RAC_API bool rac_state_token_needs_refresh(void);
191191

192192
/**
193193
* @brief Get token expiry timestamp
194194
* @return Unix timestamp (seconds) when token expires, or 0 if not set
195195
*/
196-
int64_t rac_state_get_token_expires_at(void);
196+
RAC_API int64_t rac_state_get_token_expires_at(void);
197197

198198
/**
199199
* @brief Get user ID
200200
* @return User ID string or NULL (do not free)
201201
*/
202-
const char* rac_state_get_user_id(void);
202+
RAC_API const char* rac_state_get_user_id(void);
203203

204204
/**
205205
* @brief Get organization ID
206206
* @return Organization ID string or NULL (do not free)
207207
*/
208-
const char* rac_state_get_organization_id(void);
208+
RAC_API const char* rac_state_get_organization_id(void);
209209

210210
/**
211211
* @brief Clear authentication state
212212
*
213213
* Called on logout or auth failure. Clears tokens but not device/env config.
214214
*/
215-
void rac_state_clear_auth(void);
215+
RAC_API void rac_state_clear_auth(void);
216216

217217
// =============================================================================
218218
// Device State Management
@@ -222,13 +222,13 @@ void rac_state_clear_auth(void);
222222
* @brief Set device registration status
223223
* @param registered Whether device is registered with backend
224224
*/
225-
void rac_state_set_device_registered(bool registered);
225+
RAC_API void rac_state_set_device_registered(bool registered);
226226

227227
/**
228228
* @brief Check if device is registered
229229
* @return true if device has been registered
230230
*/
231-
bool rac_state_is_device_registered(void);
231+
RAC_API bool rac_state_is_device_registered(void);
232232

233233
// =============================================================================
234234
// State Change Callbacks (for platform observers)
@@ -249,7 +249,7 @@ typedef void (*rac_auth_changed_callback_t)(bool is_authenticated, void* user_da
249249
* @param callback The callback function (NULL to unregister)
250250
* @param user_data Context passed to callback
251251
*/
252-
void rac_state_on_auth_changed(rac_auth_changed_callback_t callback, void* user_data);
252+
RAC_API void rac_state_on_auth_changed(rac_auth_changed_callback_t callback, void* user_data);
253253

254254
// =============================================================================
255255
// Persistence Bridge (Platform implements secure storage)
@@ -282,8 +282,8 @@ typedef const char* (*rac_load_callback_t)(const char* key, void* user_data);
282282
* @param load Callback to load a value
283283
* @param user_data Context passed to callbacks
284284
*/
285-
void rac_state_set_persistence_callbacks(rac_persist_callback_t persist, rac_load_callback_t load,
286-
void* user_data);
285+
RAC_API void rac_state_set_persistence_callbacks(rac_persist_callback_t persist,
286+
rac_load_callback_t load, void* user_data);
287287

288288
#ifdef __cplusplus
289289
}

sdk/runanywhere-flutter/packages/runanywhere/lib/native/dart_bridge_model_registry.dart

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@ class DartBridgeModelRegistry {
132132
_logger.debug('rac_model_info_alloc returned null');
133133
return false;
134134
}
135-
136135
// Temporary Dart strings for conversion
137136
final idDart = model.id.toNativeUtf8();
138137
final nameDart = model.name.toNativeUtf8();
@@ -281,9 +280,9 @@ class DartBridgeModelRegistry {
281280
static int _sourceToFfi(public_types.ModelSource source) {
282281
switch (source) {
283282
case public_types.ModelSource.remote:
284-
return 1; // RAC_MODEL_SOURCE_REMOTE
283+
return 0; // RAC_MODEL_SOURCE_REMOTE
285284
case public_types.ModelSource.local:
286-
return 2; // RAC_MODEL_SOURCE_LOCAL
285+
return 1; // RAC_MODEL_SOURCE_LOCAL
287286
}
288287
}
289288

@@ -361,9 +360,9 @@ class DartBridgeModelRegistry {
361360
/// Convert C++ RAC_MODEL_SOURCE int to public ModelSource
362361
static public_types.ModelSource _sourceFromFfi(int source) {
363362
switch (source) {
364-
case 1:
363+
case 0:
365364
return public_types.ModelSource.remote;
366-
case 2:
365+
case 1:
367366
return public_types.ModelSource.local;
368367
default:
369368
return public_types.ModelSource.remote;
@@ -789,20 +788,24 @@ class DartBridgeModelRegistry {
789788
/// Convert C struct to Dart ModelInfo using correct struct layout.
790789
/// Uses RacModelInfoCStruct which matches the actual C rac_model_info_t.
791790
ModelInfo _cStructToModelInfo(Pointer<RacModelInfoCStruct> struct) {
791+
final id = struct.ref.id.toDartString();
792+
final name = struct.ref.name.toDartString();
793+
final downloadURL = struct.ref.downloadUrl != nullptr
794+
? struct.ref.downloadUrl.toDartString()
795+
: null;
796+
final localPath = struct.ref.localPath != nullptr
797+
? struct.ref.localPath.toDartString()
798+
: null;
792799
return ModelInfo(
793-
id: struct.ref.id.toDartString(),
794-
name: struct.ref.name.toDartString(),
800+
id: id,
801+
name: name,
795802
category: struct.ref.category,
796803
format: struct.ref.format,
797804
framework: struct.ref.framework,
798805
source: struct.ref.source,
799806
sizeBytes: struct.ref.downloadSize,
800-
downloadURL: struct.ref.downloadUrl != nullptr
801-
? struct.ref.downloadUrl.toDartString()
802-
: null,
803-
localPath: struct.ref.localPath != nullptr
804-
? struct.ref.localPath.toDartString()
805-
: null,
807+
downloadURL: downloadURL,
808+
localPath: localPath,
806809
version: null,
807810
);
808811
}

0 commit comments

Comments
 (0)