Skip to content

Commit e8a2428

Browse files
committed
Merge branch 'feature-generate_uuid' of https://github.com/runrevmark/livecode into feature-generate_uuid
[[ Uuid ]] Updated to use MCU_random_bytes.
2 parents 81bf7d2 + 00a6ec4 commit e8a2428

File tree

17 files changed

+567
-8
lines changed

17 files changed

+567
-8
lines changed

engine/Android.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ LOCAL_SRC_FILES := $(addprefix src/,\
3737
externalv0.cpp externalv1.cpp \
3838
mode_standalone.cpp lextable.cpp eventqueue.cpp sha1.cpp stacke.cpp \
3939
name.cpp redraw.cpp tilecache.cpp tilecachesw.cpp tilecachegl.cpp sysregion.cpp \
40-
sysunxdate.cpp sysunxrandom.cpp sysspec.cpp stackcache.cpp \
40+
sysunxdate.cpp sysunxrandom.cpp sysspec.cpp stackcache.cpp uuid.cpp \
4141
mblad.cpp mblalert.cpp mblbusyindicator.cpp mblcalendar.cpp mblcontact.cpp mblcontrol.cpp \
4242
mbldc.cpp mbldialog.cpp mblflst.cpp mblmain.cpp mblnotification.cpp mblsensor.cpp \
4343
mblspec.cpp mblsound.cpp mblstack.cpp mblstore.cpp mbltextmessaging.cpp \

engine/Makefile.kernel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ SOURCES=\
3333
contextscalewrapper.cpp variablearray.cpp objectstream.cpp \
3434
menuparse.cpp parentscript.cpp securemode.cpp \
3535
bitmapeffect.cpp bitmapeffectblur.cpp md5.cpp sha1.cpp capsule.cpp \
36-
externalv0.cpp externalv1.cpp \
36+
externalv0.cpp externalv1.cpp uuid.cpp \
3737
dskspec.cpp sysunxdate.cpp sysunxnetwork.cpp sysunxrandom.cpp \
3838
lnxpasteboard.cpp lnxtransfer.cpp lnxclipboard.cpp \
3939
lnxdc.cpp lnxdce.cpp lnxdcs.cpp lnxdclnx.cpp lnxflst.cpp lnxflstold.cpp \

engine/Makefile.kernel-server

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ SOURCES=\
3232
contextscalewrapper.cpp variablearray.cpp objectstream.cpp \
3333
menuparse.cpp parentscript.cpp securemode.cpp \
3434
bitmapeffect.cpp bitmapeffectblur.cpp md5.cpp sha1.cpp capsule.cpp \
35-
externalv0.cpp externalv1.cpp lextable.cpp \
35+
externalv0.cpp externalv1.cpp lextable.cpp uuid.cpp \
3636
objectprops.cpp objectpropsets.cpp variablevalue.cpp mcutility.cpp notify.cpp customprinter.cpp \
3737
sysspec.cpp mode_server.cpp sysunxdate.cpp sysunxnetwork.cpp sysunxrandom.cpp \
3838
srvmain.cpp srvspec.cpp srvsession.cpp srvstack.cpp srvflst.cpp srvposix.cpp srvdebug.cpp \

engine/engine-mobile.xcodeproj/project.pbxproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@
260260
4DB322B1174BD4D100046FFE /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4DB322B0174BD4D100046FFE /* Security.framework */; };
261261
4DC684BE1348EAD7002469A4 /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4DC684BD1348EAD7002469A4 /* OpenGLES.framework */; };
262262
4DD3E17B1040BDAF00CAC7EF /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 4DD3E17A1040BDAF00CAC7EF /* libz.dylib */; };
263+
4DE5E7EB174BBE89001AB76D /* uuid.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DE5E7E6174BBE64001AB76D /* uuid.cpp */; };
263264
4DE9499E142762490072D9C6 /* CoreText.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4DE9499D142762490072D9C6 /* CoreText.framework */; };
264265
E8111F8C1541938E00DB16E3 /* CoreMotion.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E8111F8B1541938E00DB16E3 /* CoreMotion.framework */; };
265266
E8111F8E154193A500DB16E3 /* AddressBook.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E8111F8D154193A500DB16E3 /* AddressBook.framework */; };
@@ -804,6 +805,8 @@
804805
4DDD7F35134BA5DA009037A0 /* mcutility.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = mcutility.cpp; path = src/mcutility.cpp; sourceTree = "<group>"; };
805806
4DDD7F52134BA80E009037A0 /* customprinter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = customprinter.cpp; path = src/customprinter.cpp; sourceTree = "<group>"; };
806807
4DDD7F57134BA833009037A0 /* mbliphonetextlayout.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = mbliphonetextlayout.mm; path = src/mbliphonetextlayout.mm; sourceTree = "<group>"; };
808+
4DE5E7E5174BBE64001AB76D /* uuid.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = uuid.h; path = src/uuid.h; sourceTree = "<group>"; };
809+
4DE5E7E6174BBE64001AB76D /* uuid.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = uuid.cpp; path = src/uuid.cpp; sourceTree = "<group>"; };
807810
4DE7B8641330D6F200305469 /* mbliphonepick.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = mbliphonepick.mm; path = src/mbliphonepick.mm; sourceTree = "<group>"; };
808811
4DE7ED6413B33CEA002634F5 /* sysspec.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = sysspec.cpp; path = src/sysspec.cpp; sourceTree = "<group>"; };
809812
4DE9499D142762490072D9C6 /* CoreText.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreText.framework; path = System/Library/Frameworks/CoreText.framework; sourceTree = SDKROOT; };
@@ -1609,6 +1612,8 @@
16091612
4DD3DF0A1040ADFC00CAC7EF /* unicode.h */,
16101613
4DD3DF261040AE0700CAC7EF /* util.cpp */,
16111614
4DD3DF251040AE0700CAC7EF /* util.h */,
1615+
4DE5E7E6174BBE64001AB76D /* uuid.cpp */,
1616+
4DE5E7E5174BBE64001AB76D /* uuid.h */,
16121617
4DD3DF1C1040AE0700CAC7EF /* visual.cpp */,
16131618
4DD3DF1B1040AE0700CAC7EF /* visual.h */,
16141619
E84BE361170C992600807CF6 /* visualeffect.h */,
@@ -1885,6 +1890,7 @@
18851890
isa = PBXSourcesBuildPhase;
18861891
buildActionMask = 2147483647;
18871892
files = (
1893+
4DE5E7EB174BBE89001AB76D /* uuid.cpp in Sources */,
18881894
4DABCD9915ECD4700085E214 /* aclip.cpp in Sources */,
18891895
4DABCD9A15ECD4700085E214 /* answer.cpp in Sources */,
18901896
4DABCD9B15ECD4700085E214 /* ask.cpp in Sources */,

engine/engine.xcodeproj/project.pbxproj

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,7 @@
309309
4D8387201678B2C9003BEC7C /* image_rep_mutable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D83871B1678B2C9003BEC7C /* image_rep_mutable.cpp */; };
310310
4D8387211678B2C9003BEC7C /* imagebitmap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D83871C1678B2C9003BEC7C /* imagebitmap.cpp */; };
311311
4D8387221678B2C9003BEC7C /* irle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D83871D1678B2C9003BEC7C /* irle.cpp */; };
312+
4D8589F9173AAA0900B20951 /* uuid.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D8589AA173A856600B20951 /* uuid.cpp */; };
312313
4D8B47990BE7B3240046CD2F /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4D8B47960BE7B3240046CD2F /* Cocoa.framework */; };
313314
4D8B479A0BE7B3240046CD2F /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4D8B47960BE7B3240046CD2F /* Cocoa.framework */; };
314315
4D8BEC4011B9379500DED42A /* osxicon.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D8BEC3F11B9379500DED42A /* osxicon.cpp */; };
@@ -321,8 +322,9 @@
321322
4DAB7D280FF3A0100009F91E /* md5.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DAB7D270FF3A0100009F91E /* md5.cpp */; };
322323
4DADCD5B12392EAF003CD17C /* sha1.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DADCD5912392EAF003CD17C /* sha1.cpp */; };
323324
4DADCDFD12393F55003CD17C /* Installer.icns in Resources */ = {isa = PBXBuildFile; fileRef = 4DADCDFC12393F26003CD17C /* Installer.icns */; };
324-
4DB32245174BD2BD00046FFE /* sysosxrandom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DB32230174BD08E00046FFE /* sysosxrandom.cpp */; };
325-
4DB32264174BD48C00046FFE /* sysosxrandom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DB32230174BD08E00046FFE /* sysosxrandom.cpp */; };
325+
4DB32401174BEE1400046FFE /* sysunxrandom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DB3222E174BD06200046FFE /* sysunxrandom.cpp */; };
326+
4DB32402174BEE1900046FFE /* uuid.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D8589AA173A856600B20951 /* uuid.cpp */; };
327+
4DB32404174BEE3300046FFE /* sysosxrandom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DB32230174BD08E00046FFE /* sysosxrandom.cpp */; };
326328
4DB382EE1714418A00D3F102 /* libz.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4D6C797917134897000BCF78 /* libz.a */; };
327329
4DB382EF1714418A00D3F102 /* libpng.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4D6C7981171348A6000BCF78 /* libpng.a */; };
328330
4DB382F01714418A00D3F102 /* libjpeg.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4D6C7989171348B4000BCF78 /* libjpeg.a */; };
@@ -1165,6 +1167,8 @@
11651167
4D8387241678B2F4003BEC7C /* flst.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = flst.h; path = src/flst.h; sourceTree = "<group>"; };
11661168
4D8387251678B2F4003BEC7C /* image_rep.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = image_rep.h; path = src/image_rep.h; sourceTree = "<group>"; };
11671169
4D8387261678B2F4003BEC7C /* imagebitmap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = imagebitmap.h; path = src/imagebitmap.h; sourceTree = "<group>"; };
1170+
4D8589AA173A856600B20951 /* uuid.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = uuid.cpp; path = src/uuid.cpp; sourceTree = "<group>"; };
1171+
4D8589AC173A88D700B20951 /* uuid.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = uuid.h; path = src/uuid.h; sourceTree = "<group>"; };
11681172
4D88B73815F4C66F002CFBD6 /* libgif.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = libgif.xcodeproj; path = ../thirdparty/libgif/libgif.xcodeproj; sourceTree = SOURCE_ROOT; };
11691173
4D8B47960BE7B3240046CD2F /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = "<absolute>"; };
11701174
4D8BEC3F11B9379500DED42A /* osxicon.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = osxicon.cpp; path = src/osxicon.cpp; sourceTree = "<group>"; };
@@ -2411,6 +2415,8 @@
24112415
4DD27ACC0D5B3A280000CC15 /* unicode.h */,
24122416
4D587E8D0B8096FD00200116 /* util.cpp */,
24132417
4D587E1D0B8096E600200116 /* util.h */,
2418+
4D8589AA173A856600B20951 /* uuid.cpp */,
2419+
4D8589AC173A88D700B20951 /* uuid.h */,
24142420
);
24152421
name = "Core - Misc";
24162422
sourceTree = "<group>";
@@ -3111,6 +3117,8 @@
31113117
4D1F9DB2171C682E0091C6CB /* irle.cpp in Sources */,
31123118
4D1F9DB3171C682E0091C6CB /* stackcache.cpp in Sources */,
31133119
4D1F9DB4171C682E0091C6CB /* stacksecurity.cpp in Sources */,
3120+
4DB32401174BEE1400046FFE /* sysunxrandom.cpp in Sources */,
3121+
4DB32402174BEE1900046FFE /* uuid.cpp in Sources */,
31143122
);
31153123
runOnlyForDeploymentPostprocessing = 0;
31163124
};
@@ -3161,7 +3169,6 @@
31613169
buildActionMask = 2147483647;
31623170
files = (
31633171
4D221F46171D632600E7E557 /* startupstack.cpp in Sources */,
3164-
4DB32245174BD2BD00046FFE /* sysosxrandom.cpp in Sources */,
31653172
);
31663173
runOnlyForDeploymentPostprocessing = 0;
31673174
};
@@ -3355,6 +3362,8 @@
33553362
4D8387221678B2C9003BEC7C /* irle.cpp in Sources */,
33563363
E8DDE5DF16C2B1A7007367E4 /* image_rep_transformed.cpp in Sources */,
33573364
E8DDE5E016C2B1A7007367E4 /* image_rep.cpp in Sources */,
3365+
4D8589F9173AAA0900B20951 /* uuid.cpp in Sources */,
3366+
4DB32404174BEE3300046FFE /* sysosxrandom.cpp in Sources */,
33583367
);
33593368
runOnlyForDeploymentPostprocessing = 0;
33603369
};
@@ -3363,7 +3372,6 @@
33633372
buildActionMask = 2147483647;
33643373
files = (
33653374
4D221AAB171D593800E7E557 /* dummy.cpp in Sources */,
3366-
4DB32264174BD48C00046FFE /* sysosxrandom.cpp in Sources */,
33673375
);
33683376
runOnlyForDeploymentPostprocessing = 0;
33693377
};

engine/kernel-server.vcproj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -923,6 +923,14 @@
923923
RelativePath=".\src\util.h"
924924
>
925925
</File>
926+
<File
927+
RelativePath=".\src\uuid.cpp"
928+
>
929+
</File>
930+
<File
931+
RelativePath=".\src\uuid.h"
932+
>
933+
</File>
926934
</Filter>
927935
<Filter
928936
Name="Core - Objects"

engine/kernel.vcproj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1390,6 +1390,14 @@
13901390
RelativePath="src\util.h"
13911391
>
13921392
</File>
1393+
<File
1394+
RelativePath=".\src\uuid.cpp"
1395+
>
1396+
</File>
1397+
<File
1398+
RelativePath=".\src\uuid.h"
1399+
>
1400+
</File>
13931401
</Filter>
13941402
<Filter
13951403
Name="_Derived"

engine/src/executionerrors.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2374,6 +2374,27 @@ enum Exec_errors
23742374

23752375
// {EE-0782} controls don't have the same owner
23762376
EE_GROUP_DIFFERENTPARENT,
2377+
2378+
// {EE-0783} uuid: bad type expression
2379+
EE_UUID_BADTYPE,
2380+
2381+
// {EE-0784} uuid: wrong number of arguments for specified type
2382+
EE_UUID_TOOMANYPARAMS,
2383+
2384+
// {EE-0785} uuid: unsupported type
2385+
EE_UUID_UNKNOWNTYPE,
2386+
2387+
// {EE-0786} uuid: bad namespace expression
2388+
EE_UUID_BADNAMESPACEID,
2389+
2390+
// {EE-0787} uuid: namespace not a uuid
2391+
EE_UUID_NAMESPACENOTAUUID,
2392+
2393+
// {EE-0788} uuid: bad name expression
2394+
EE_UUID_BADNAME,
2395+
2396+
// {EE-0789} uuid: not enough randomness available
2397+
EE_UUID_NORANDOMNESS,
23772398
};
23782399

23792400
extern const char *MCexecutionerrors;

engine/src/funcs.cpp

Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ along with LiveCode. If not see <http://www.gnu.org/licenses/>. */
5757
#include "license.h"
5858
#include "mode.h"
5959
#include "stacksecurity.h"
60+
#include "uuid.h"
6061

6162
#include "core.h"
6263

@@ -6107,6 +6108,8 @@ char *MCHTTPProxyForURL::PACmyIpAddress(const char* const* p_arguments, unsigned
61076108
return t_address;
61086109
}
61096110

6111+
///////////////////////////////////////////////////////////////////////////////
6112+
61106113
MCRandomBytes::~MCRandomBytes()
61116114
{
61126115
delete byte_count;
@@ -6155,6 +6158,8 @@ Exec_stat MCRandomBytes::eval(MCExecPoint &ep)
61556158
return ES_NORMAL;
61566159
}
61576160

6161+
///////////////////////////////////////////////////////////////////////////////
6162+
61586163
MCControlAtLoc::~MCControlAtLoc()
61596164
{
61606165
delete location;
@@ -6223,3 +6228,160 @@ Exec_stat MCControlAtLoc::eval(MCExecPoint &ep)
62236228
return ES_NORMAL;
62246229
}
62256230

6231+
///////////////////////////////////////////////////////////////////////////////
6232+
6233+
MCUuidFunc::~MCUuidFunc(void)
6234+
{
6235+
delete type;
6236+
delete name;
6237+
delete namespace_id;
6238+
}
6239+
6240+
// Syntax:
6241+
// uuid() - random uuid
6242+
// uuid("random") - random uuid
6243+
// uuid("md5" | "sha1", <namespace_id>, <name>)
6244+
// So either 0, 1, or 3 parameters.
6245+
Parse_stat MCUuidFunc::parse(MCScriptPoint& sp, Boolean the)
6246+
{
6247+
// Parameters are parsed by 'getexps' into this array.
6248+
MCExpression *earray[MAX_EXP];
6249+
uint2 ecount = 0;
6250+
6251+
// Parse the parameters and check that there are 0, 1 or 3 of them.
6252+
if (getexps(sp, earray, ecount) != PS_NORMAL || (ecount != 0 && ecount == 1 && ecount == 3))
6253+
{
6254+
// If there are the wrong number of params, free the exps.
6255+
freeexps(earray, ecount);
6256+
6257+
// Throw a parse error.
6258+
MCperror -> add(PE_UUID_BADPARAM, sp);
6259+
return PS_ERROR;
6260+
}
6261+
6262+
// Assign the expressions as appropriate.
6263+
if (ecount > 0)
6264+
{
6265+
type = earray[0];
6266+
6267+
if (ecount > 1)
6268+
{
6269+
namespace_id = earray[1];
6270+
name = earray[2];
6271+
}
6272+
}
6273+
6274+
// We are done, so return.
6275+
return PS_NORMAL;
6276+
}
6277+
6278+
Exec_stat MCUuidFunc::eval(MCExecPoint& ep)
6279+
{
6280+
// First work out what type we want.
6281+
MCUuidType t_type;
6282+
if (type == nil)
6283+
t_type = kMCUuidTypeRandom;
6284+
else
6285+
{
6286+
if (type -> eval(ep) != ES_NORMAL)
6287+
{
6288+
MCeerror -> add(EE_UUID_BADTYPE, line, pos);
6289+
return ES_ERROR;
6290+
}
6291+
6292+
if (ep . getsvalue() == "random")
6293+
{
6294+
// If there is more than one parameter, it's an error.
6295+
if (name != nil)
6296+
{
6297+
MCeerror -> add(EE_UUID_TOOMANYPARAMS, line, pos);
6298+
return ES_ERROR;
6299+
}
6300+
6301+
t_type = kMCUuidTypeRandom;
6302+
}
6303+
else if (ep . getsvalue() == "md5")
6304+
t_type = kMCUuidTypeMD5;
6305+
else if (ep . getsvalue() == "sha1")
6306+
t_type = kMCUuidTypeSHA1;
6307+
else
6308+
{
6309+
// If the type isn't one of 'random', 'md5', 'sha1' then it's
6310+
// an error.
6311+
MCeerror -> add(EE_UUID_UNKNOWNTYPE, line, pos);
6312+
return ES_ERROR;
6313+
}
6314+
}
6315+
6316+
// If it is not of random type, then evaluate the other params.
6317+
MCUuid t_namespace_id;
6318+
MCString t_name;
6319+
if (t_type != kMCUuidTypeRandom)
6320+
{
6321+
// If there aren't namespace_id and name exprs, its an error.
6322+
if (namespace_id == nil || name == nil)
6323+
{
6324+
MCeerror -> add(EE_UUID_TOOMANYPARAMS, line, pos);
6325+
return ES_ERROR;
6326+
}
6327+
6328+
// Evaluate the namespace parameter.
6329+
if (namespace_id -> eval(ep) != ES_NORMAL)
6330+
{
6331+
MCeerror -> add(EE_UUID_BADNAMESPACEID, line, pos);
6332+
return ES_ERROR;
6333+
}
6334+
6335+
// Attempt to convert it to a uuid.
6336+
if (!MCUuidFromCString(ep . getcstring(), t_namespace_id))
6337+
{
6338+
MCeerror -> add(EE_UUID_NAMESPACENOTAUUID, line, pos);
6339+
return ES_ERROR;
6340+
}
6341+
6342+
// Evaluate the name parameter.
6343+
if (name -> eval(ep) != ES_NORMAL)
6344+
{
6345+
MCeerror -> add(EE_UUID_BADNAME, line, pos);
6346+
return ES_ERROR;
6347+
}
6348+
6349+
// Borrow the value from the ep - this is okay in this instance because
6350+
// ep isn't used again until the name has been utilised.
6351+
t_name = ep . getsvalue();
6352+
}
6353+
6354+
// Generate the uuid.
6355+
MCUuid t_uuid;
6356+
switch(t_type)
6357+
{
6358+
case kMCUuidTypeRandom:
6359+
if (!MCUuidGenerateRandom(t_uuid))
6360+
{
6361+
MCeerror -> add(EE_UUID_NORANDOMNESS, line, pos);
6362+
return ES_ERROR;
6363+
}
6364+
break;
6365+
6366+
case kMCUuidTypeMD5:
6367+
MCUuidGenerateMD5(t_namespace_id, t_name, t_uuid);
6368+
break;
6369+
6370+
case kMCUuidTypeSHA1:
6371+
MCUuidGenerateSHA1(t_namespace_id, t_name, t_uuid);
6372+
break;
6373+
6374+
default:
6375+
assert(false);
6376+
break;
6377+
}
6378+
6379+
// Convert the uuid to a string.
6380+
char t_uuid_buffer[kMCUuidCStringLength];
6381+
MCUuidToCString(t_uuid, t_uuid_buffer);
6382+
6383+
// And set it as the return value (in the ep).
6384+
ep . copysvalue(t_uuid_buffer);
6385+
6386+
return ES_NORMAL;
6387+
}

0 commit comments

Comments
 (0)