Skip to content

Commit b8f6142

Browse files
committed
Merge pull request livecode#2168 from livecodeali/bugfix-14603
Enable selective module inclusion in standalones
2 parents 91d00d5 + 45456bd commit b8f6142

File tree

5 files changed

+36
-51
lines changed

5 files changed

+36
-51
lines changed

engine/src/cmdsc.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2351,6 +2351,17 @@ Parse_stat MCLoad::parse(MCScriptPoint &sp)
23512351
{
23522352
is_extension = true;
23532353

2354+
if (sp.skip_token(SP_FACTOR, TT_FROM) != PS_NORMAL)
2355+
{
2356+
MCperror->add(PE_LOAD_NOFROM, sp);
2357+
return PS_ERROR;
2358+
}
2359+
if (sp.skip_token(SP_OPEN, TT_UNDEFINED) != PS_NORMAL)
2360+
{
2361+
MCperror->add(PE_LOAD_NOFILE, sp);
2362+
return PS_ERROR;
2363+
}
2364+
23542365
if (sp.parseexp(False, True, &url) != PS_NORMAL)
23552366
{
23562367
MCperror->add(PE_LOAD_BADEXTENSION, sp);

engine/src/deploy.cpp

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -405,29 +405,6 @@ bool MCDeployWriteCapsule(const MCDeployParameters& p_params, MCDeployFileRef p_
405405
t_success = MCDeployCapsuleDefineFromFile(t_capsule, kMCCapsuleSectionTypeModule, t_module_files[i]);
406406
}
407407

408-
// TEMPORARY - Iterator through all loaded extensions and add them to the list.
409-
if (t_success)
410-
{
411-
extern bool MCEngineIterateExtensionFilenames(uintptr_t& x_iterator, MCStringRef& r_filename);
412-
MCStringRef t_filename;
413-
uintptr_t t_iterator;
414-
t_iterator = 0;
415-
while(t_success && MCEngineIterateExtensionFilenames(t_iterator, t_filename))
416-
{
417-
MCDeployFileRef t_file;
418-
t_file = nil;
419-
if (t_success &&
420-
!MCDeployFileOpen(t_filename, kMCOpenFileModeRead, t_file))
421-
t_success = MCDeployThrow(kMCDeployErrorNoModule);
422-
if (t_success)
423-
t_success = t_module_files . Push(t_file);
424-
if (t_success)
425-
t_success = MCDeployCapsuleDefineFromFile(t_capsule, kMCCapsuleSectionTypeModule, t_file);
426-
if (!t_success && t_file != nil)
427-
MCDeployFileClose(t_file);
428-
}
429-
}
430-
431408
////////
432409

433410

engine/src/exec-extension.cpp

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
struct MCLoadedExtension
5656
{
5757
MCLoadedExtension *next;
58-
MCStringRef filename;
58+
MCNameRef module_name;
5959
MCStringRef resource_path;
6060
MCScriptModuleRef module;
6161
MCScriptInstanceRef instance;
@@ -125,7 +125,7 @@ bool MCEngineAddExtensionFromModule(MCStringRef p_filename, MCScriptModuleRef p_
125125
MCLoadedExtension *t_ext;
126126
/* UNCHECKED */ MCMemoryNew(t_ext);
127127

128-
t_ext -> filename = MCValueRetain(p_filename);
128+
t_ext -> module_name = MCValueRetain(MCScriptGetNameOfModule(p_module));
129129
t_ext -> module = MCScriptRetainModule(p_module);
130130
t_ext -> instance = t_instance;
131131

@@ -178,10 +178,6 @@ void MCEngineExecLoadExtension(MCExecContext& ctxt, MCStringRef p_filename, MCSt
178178
if (!MCS_loadbinaryfile(*t_resolved_filename, &t_data))
179179
return;
180180

181-
for(MCLoadedExtension *t_ext = MCextensions; t_ext != nil; t_ext = t_ext -> next)
182-
if (MCStringIsEqualTo(t_ext -> filename, *t_resolved_filename, kMCStringOptionCompareCaseless))
183-
return;
184-
185181
MCStreamRef t_stream;
186182
/* UNCHECKED */ MCMemoryInputStreamCreate(MCDataGetBytePtr(*t_data), MCDataGetLength(*t_data), t_stream);
187183

@@ -205,22 +201,21 @@ void MCEngineExecLoadExtension(MCExecContext& ctxt, MCStringRef p_filename, MCSt
205201

206202
MCScriptReleaseModule(t_module);
207203

208-
209204
return;
210205
}
211206

212-
void MCEngineExecUnloadExtension(MCExecContext& ctxt, MCStringRef p_filename)
207+
void MCEngineExecUnloadExtension(MCExecContext& ctxt, MCStringRef p_module_name)
213208
{
214-
MCAutoStringRef t_resolved_filename;
215-
/* UNCHECKED */ MCS_resolvepath(p_filename, &t_resolved_filename);
209+
MCNewAutoNameRef t_name;
210+
MCNameCreate(p_module_name, &t_name);
216211

217212
for(MCLoadedExtension *t_previous = nil, *t_ext = MCextensions; t_ext != nil; t_previous = t_ext, t_ext = t_ext -> next)
218-
if (MCStringIsEqualTo(t_ext -> filename, *t_resolved_filename, kMCStringOptionCompareCaseless))
213+
if (MCNameIsEqualTo(t_ext -> module_name, *t_name))
219214
{
220215
if (t_ext -> instance != nil)
221216
MCScriptReleaseInstance(t_ext -> instance);
222217
MCScriptReleaseModule(t_ext -> module);
223-
MCValueRelease(t_ext -> filename);
218+
MCValueRelease(t_ext -> module_name);
224219
MCValueRelease(t_ext -> resource_path);
225220
if (t_previous != nil)
226221
t_previous -> next = t_ext -> next;
@@ -245,7 +240,7 @@ void MCEngineGetLoadedExtensions(MCExecContext& ctxt, MCProperListRef& r_list)
245240
t_success = MCProperListCreateMutable(t_list);
246241

247242
for(MCLoadedExtension *t_ext = MCextensions; t_success && t_ext != nil; t_ext = t_ext -> next)
248-
t_success = MCProperListPushElementOntoBack(t_list, MCScriptGetNameOfModule(t_ext -> module));
243+
t_success = MCProperListPushElementOntoBack(t_list, t_ext -> module_name);
249244

250245
if (t_success)
251246
t_success = MCProperListCopyAndRelease(t_list, r_list);
@@ -258,21 +253,6 @@ void MCEngineGetLoadedExtensions(MCExecContext& ctxt, MCProperListRef& r_list)
258253
}
259254
}
260255

261-
bool MCEngineIterateExtensionFilenames(uintptr_t& x_iterator, MCStringRef& r_filename)
262-
{
263-
if (x_iterator == 0)
264-
x_iterator = (uintptr_t)MCextensions;
265-
else
266-
x_iterator = (uintptr_t)(((MCLoadedExtension *)x_iterator) -> next);
267-
268-
if (x_iterator == 0)
269-
return false;
270-
271-
r_filename = ((MCLoadedExtension *)x_iterator) -> filename;
272-
273-
return true;
274-
}
275-
276256
Exec_stat MCEngineHandleLibraryMessage(MCNameRef p_message, MCParameter *p_parameters)
277257
{
278258
if (MCextensionschanged)

engine/src/parseerrors.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1718,6 +1718,12 @@ enum Parse_errors
17181718

17191719
// {PE-0558} load: error in resource path expression
17201720
PE_LOAD_BADRESOURCEPATH,
1721+
1722+
// {PE-0559} load: missing file or display name
1723+
PE_LOAD_NOFILE,
1724+
1725+
// {PE-0195} load: missing 'from'
1726+
PE_LOAD_NOFROM,
17211727
};
17221728

17231729
extern const char *MCparsingerrors;

ide-support/revsaveasstandalone.livecodescript

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2265,6 +2265,17 @@ private command revBuildStandaloneDeploy pPlatform, pStackFilePath, pEnginePath,
22652265
put sStandaloneSettingsA[tPlatformDetailsA["platform"] & ",library"] into tDeployInfo["library"]
22662266
end if
22672267

2268+
# AL-2015-04-12: [[ Standalone Extensions ]] Add chosen extensions to the standalone inclusions
2269+
repeat for each line tExtension in sStandaloneSettingsA["extensions"]
2270+
local tExtensionFile
2271+
put revIDEExtensionModuleFile(tExtension) into tExtensionFile
2272+
if tDeployInfo["modules"] is empty then
2273+
put tExtensionFile into tDeployInfo["modules"]
2274+
else
2275+
put return & tExtensionFile after tDeployInfo["modules"]
2276+
end if
2277+
end repeat
2278+
22682279
if tPlatformDetailsA["platform"] is "MacOSX" then
22692280
-- MW-2013-06-13: [[ CloneAndRun ]] If installed do things in the usual way, otherwise pass
22702281
-- through in 'engine' (so it builds using archs present there).

0 commit comments

Comments
 (0)