Skip to content

Commit ddf138a

Browse files
committed
Tweaks to refactor and implement intset_t setprop
1 parent 2e15ae3 commit ddf138a

10 files changed

Lines changed: 137 additions & 46 deletions

engine/kernel.vcproj

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3541,7 +3541,6 @@
35413541
>
35423542
<FileConfiguration
35433543
Name="Debug|Win32"
3544-
ExcludedFromBuild="true"
35453544
>
35463545
<Tool
35473546
Name="VCCLCompilerTool"
@@ -3561,7 +3560,6 @@
35613560
>
35623561
<FileConfiguration
35633562
Name="Debug|Win32"
3564-
ExcludedFromBuild="true"
35653563
>
35663564
<Tool
35673565
Name="VCCustomBuildTool"
@@ -4450,6 +4448,18 @@
44504448
/>
44514449
</FileConfiguration>
44524450
</File>
4451+
<File
4452+
RelativePath=".\src\mblandroidideltimer.cpp"
4453+
>
4454+
<FileConfiguration
4455+
Name="Debug|Win32"
4456+
ExcludedFromBuild="true"
4457+
>
4458+
<Tool
4459+
Name="VCCLCompilerTool"
4460+
/>
4461+
</FileConfiguration>
4462+
</File>
44534463
<File
44544464
RelativePath=".\src\mblandroidinput.cpp"
44554465
>
@@ -5162,6 +5172,10 @@
51625172
/>
51635173
</FileConfiguration>
51645174
</File>
5175+
<File
5176+
RelativePath=".\src\mbliphoneidletimer.mm"
5177+
>
5178+
</File>
51655179
<File
51665180
RelativePath=".\src\mbliphoneinput.mm"
51675181
>
@@ -6450,13 +6464,6 @@
64506464
<File
64516465
RelativePath=".\src\exec-mail.cpp"
64526466
>
6453-
<FileConfiguration
6454-
Name="Debug|Win32"
6455-
>
6456-
<Tool
6457-
Name="VCCLCompilerTool"
6458-
/>
6459-
</FileConfiguration>
64606467
</File>
64616468
<File
64626469
RelativePath=".\src\exec-math.cpp"
@@ -6470,20 +6477,17 @@
64706477
RelativePath=".\src\exec-multimedia.cpp"
64716478
>
64726479
</File>
6480+
<File
6481+
RelativePath=".\src\exec-nativecontrol.cpp"
6482+
>
6483+
</File>
64736484
<File
64746485
RelativePath=".\src\exec-network.cpp"
64756486
>
64766487
</File>
64776488
<File
64786489
RelativePath=".\src\exec-orientation.cpp"
64796490
>
6480-
<FileConfiguration
6481-
Name="Debug|Win32"
6482-
>
6483-
<Tool
6484-
Name="VCCLCompilerTool"
6485-
/>
6486-
</FileConfiguration>
64876491
</File>
64886492
<File
64896493
RelativePath=".\src\exec-pasteboard.cpp"

engine/src/exec-orientation.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ static MCExecEnumTypeInfo _kMCOrientationOrientationTypeInfo =
7171

7272
////////////////////////////////////////////////////////////////////////////////
7373

74+
MCExecSetTypeInfo *kMCOrientationOrientationsTypeInfo = &_kMCOrientationOrientationsTypeInfo;
75+
MCExecEnumTypeInfo *kMCOrientationOrientationTypeInfo = &_kMCOrientationOrientationTypeInfo;
76+
77+
////////////////////////////////////////////////////////////////////////////////
78+
7479
void MCOrientationGetDeviceOrientation(MCExecContext& ctxt, intenum_t& r_orientation)
7580
{
7681
MCOrientation t_orientation;
@@ -87,15 +92,15 @@ void MCOrientationGetOrientation(MCExecContext& ctxt, intenum_t& r_orientation)
8792

8893
void MCOrientationGetAllowedOrientations(MCExecContext& ctxt, intset_t& r_orientations)
8994
{
90-
MCOrientationSet t_orientations;
95+
uint32_t t_orientations;
9196
MCSystemGetAllowedOrientations(t_orientations);
9297
r_orientations = (intset_t)t_orientations;
9398
}
9499

95100
void MCOrientationSetAllowedOrientations(MCExecContext& ctxt, intset_t p_orientations)
96101
{
97-
MCOrientationSet t_orientations;
98-
t_orientations = (MCOrientationSet)p_orientations;
102+
uint32_t t_orientations;
103+
t_orientations = (uint32_t)p_orientations;
99104
MCSystemSetAllowedOrientations(t_orientations);
100105
}
101106

engine/src/exec.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3429,6 +3429,9 @@ void MCStoreExecPurchaseVerify(MCExecContext& ctxt, uint32_t p_id, bool p_verifi
34293429

34303430
///////////
34313431

3432+
extern MCExecSetTypeInfo *kMCOrientationOrientationsTypeInfo;
3433+
extern MCExecEnumTypeInfo *kMCOrientationOrientationTypeInfo;
3434+
34323435
extern MCExecMethodInfo *kMCOrientationGetDeviceOrientationMethodInfo;
34333436
extern MCExecMethodInfo *kMCOrientationGetOrientationMethodInfo;
34343437
extern MCExecMethodInfo *kMCOrientationGetAllowedOrientationsMethodInfo;

engine/src/mblandroidorientation.cpp

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -368,24 +368,46 @@ MCOrientation get_orientation(MCAndroidDisplayOrientation p_orientation)
368368
}
369369
}
370370

371-
MCOrientationSet get_orientation_set(uint32_t p_orientations)
371+
uint32_t get_orientation_set(uint32_t p_orientations)
372372
{
373-
// UNIMPLEMENTED
374-
return ORIENTATION_UNKNOWN_BIT
373+
uint32_t t_orientations = 0;
374+
if (p_orientations & (1 << kMCDisplayOrientationPortrait))
375+
t_orientations |= ORIENTATION_PORTRAIT_BIT;
376+
if (p_orientations & (1 << kMCDisplayOrientationPortraitUpsideDown))
377+
t_orientations |= ORIENTATION_PORTRAIT_UPSIDE_DOWN_BIT;
378+
if (p_orientations & (1 << kMCDisplayOrientationLandscapeRight))
379+
t_orientations |= ORIENTATION_LANDSCAPE_RIGHT_BIT;
380+
if (p_orientations & (1 << kMCDisplayOrientationLandscapeLeft))
381+
t_orientations |= ORIENTATION_LANDSCAPE_LEFT_BIT;
382+
if (p_orientations & (1 << kMCDisplayOrientationFaceUp))
383+
t_orientations |= ORIENTATION_FACE_UP_BIT;
384+
385+
return t_orientations;
375386
}
376387

377-
uint32_t get_android_orientations(MCOrientationSet p_orientations)
388+
uint32_t get_android_orientations(uint32_t p_orientations)
378389
{
379-
//UNIMPLEMENTED
380-
return 0;
390+
uint32_t t_orientations = 0;
391+
if (p_orientations & (1 << ORIENTATION_PORTRAIT_BIT))
392+
t_orientations |= kMCDisplayOrientationPortrait;
393+
if (p_orientations & (1 << ORIENTATION_PORTRAIT_UPSIDE_DOWN_BIT))
394+
t_orientations |= kMCDisplayOrientationPortraitUpsideDown;
395+
if (p_orientations & (1 << ORIENTATION_LANDSCAPE_RIGHT_BIT))
396+
t_orientations |= kMCDisplayOrientationLandscapeRight;
397+
if (p_orientations & (1 << ORIENTATION_LANDSCAPE_LEFT_BIT))
398+
t_orientations |= kMCDisplayOrientationLandscapeLeft;
399+
if (p_orientations & (1 << ORIENTATION_FACE_UP_BIT))
400+
t_orientations |= kMCDisplayOrientationFaceUp;
401+
402+
return t_orientations;
381403
}
382404

383-
void MCSystemGetAllowedOrientations(MCOrientationSet& r_orientations)
405+
void MCSystemGetAllowedOrientations(uint32_t& r_orientations)
384406
{
385407
r_orientations = get_orientation_set(s_allowed_orientations);
386408
}
387409

388-
void MCSystemSetAllowedOrientations(MCOrientationSet p_orientations)
410+
void MCSystemSetAllowedOrientations(uint32_t p_orientations)
389411
{
390412
s_allowed_orientations = get_android_orientations(p_orientations);
391413
}

engine/src/mblcontrol.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,16 +136,16 @@ void MCNativeControl::SetOwner(MCObject *p_owner)
136136
m_object = p_owner -> gethandle();
137137
}
138138

139-
bool MCNativeControl::SetName(const char *p_name)
139+
bool MCNativeControl::SetName(MCStringRef p_name)
140140
{
141141
if (m_name != nil)
142142
{
143143
MCCStringFree(m_name);
144144
m_name = nil;
145145
}
146146

147-
if (p_name != nil)
148-
return MCCStringClone(p_name, m_name);
147+
if (p_name != nil)
148+
return MCCStringClone(MCStringGetCString(p_name), m_name);
149149

150150
return true;
151151
}

engine/src/mblcontrol.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ class MCNativeControl
280280
// The id of the instance
281281
uint32_t m_id;
282282
// The name of the instance
283-
char *m_name;
283+
MCStringRef m_name;
284284
// The instance's owning object (handle)
285285
MCObjectHandle *m_object;
286286
};

engine/src/mbliphoneorientation.mm

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,16 +70,35 @@ MCOrientation get_orientation(UIInterfaceOrientation p_orientation)
7070
}
7171
}
7272

73-
MCOrientationSet get_orientation_set(uint32_t p_orientations)
73+
uint32_t get_orientation_set(uint32_t p_orientations)
7474
{
75-
//UNIMPLEMENTED
76-
return ORIENTATION_UNKNOWN_BIT;
75+
uint32_t t_orientations = 0;
76+
77+
if (p_orientations & (1 << UIInterfaceOrientationPortrait))
78+
t_orientations |= ORIENTATION_PORTRAIT_BIT;
79+
if (p_orientations & (1 << UIInterfaceOrientationPortraitUpsideDown))
80+
t_orientations |= ORIENTATION_PORTRAIT_UPSIDE_DOWN_BIT;
81+
if (p_orientations & (1 << kMCDisplayOrientationLandscapeRight))
82+
t_orientations |= ORIENTATION_LANDSCAPE_RIGHT_BIT;
83+
if (p_orientations & (1 << kMCDisplayOrientationLandscapeLeft))
84+
t_orientations |= ORIENTATION_LANDSCAPE_LEFT_BIT;
85+
86+
return t_orientations;
7787
}
7888

79-
uint32_t get_iphone_orientation(MCOrientationSet p_orientations)
89+
uint32_t get_iphone_orientations(uint32_t p_orientations)
8090
{
81-
//UNIMPLEMENTED
82-
return 0;
91+
uint32_t t_orientations = 0;
92+
if (p_orientations & (1 << ORIENTATION_PORTRAIT_BIT))
93+
t_orientations |= UIInterfaceOrientationPortrait;
94+
if (p_orientations & (1 << ORIENTATION_PORTRAIT_UPSIDE_DOWN_BIT))
95+
t_orientations |= UIInterfaceOrientationPortraitUpsideDown;
96+
if (p_orientations & (1 << ORIENTATION_LANDSCAPE_RIGHT_BIT))
97+
t_orientations |= UIInterfaceOrientationLandscapeRight;
98+
if (p_orientations & (1 << ORIENTATION_LANDSCAPE_LEFT_BIT))
99+
t_orientations |= UIInterfaceOrientationLandscapeLeft;
100+
101+
return t_orientations;
83102
}
84103

85104
void MCSystemGetDeviceOrientation(MCOrientation& r_orientation)
@@ -92,14 +111,14 @@ void MCSystemGetOrientation(MCOrientation& r_orientation)
92111
r_orientation = get_orientation(MCIPhoneGetOrientation());
93112
}
94113

95-
void MCSystemGetAllowedOrientations(MCOrientationSet& r_orientations)
114+
void MCSystemGetAllowedOrientations(uint32_t& r_orientations)
96115
{
97116
r_orientations = get_orientation_set([MCIPhoneGetApplication() allowedOrientations]);
98117
}
99118

100-
void MCSystemSetAllowedOrientations(MCOrientationSet p_orientations)
119+
void MCSystemSetAllowedOrientations(uint32_t p_orientations)
101120
{
102-
[MCIPhoneGetApplication() setAllowedOrientations: get_iphone_orientation(p_orientations)];
121+
[MCIPhoneGetApplication() setAllowedOrientations: get_iphone_orientations(p_orientations)];
103122
}
104123

105124
void MCSystemGetOrientationLocked(bool& r_locked)

engine/src/mblsyntax.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,8 +299,8 @@ typedef enum
299299
ORIENTATION_FACE_DOWN_BIT = 1 << ORIENTATION_FACE_DOWN
300300
} MCOrientationSet;
301301

302-
void MCSystemGetAllowedOrientations(MCOrientationSet& r_orientations);
303-
void MCSystemSetAllowedOrientations(MCOrientationSet p_orientations);
302+
void MCSystemGetAllowedOrientations(uint32_t& r_orientations);
303+
void MCSystemSetAllowedOrientations(uint32_t p_orientations);
304304
void MCSystemGetOrientation(MCOrientation& r_orientation);
305305
void MCSystemGetDeviceOrientation(MCOrientation& r_orientation);
306306
void MCSystemLockOrientation();

engine/src/objectprops.cpp

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2561,8 +2561,31 @@ Exec_stat MCObject::setprop(uint32_t p_part_id, Properties p_which, MCExecPoint&
25612561
break;
25622562

25632563
case kMCPropertyTypeSet:
2564-
ctxt . Unimplemented();
2565-
break;
2564+
{
2565+
MCExecSetTypeInfo *t_set_info;
2566+
t_set_info = (MCExecSetTypeInfo *)(t_info -> type_info);
2567+
2568+
intset_t t_value = 0;
2569+
char **t_elements;
2570+
uindex_t t_element_count;
2571+
MCCStringSplit(ep . getcstring(), ',', t_elements, t_element_count);
2572+
2573+
for (uindex_t i = 0; i < t_element_count; i++)
2574+
{
2575+
for (uindex_t j = 0; j < t_set_info -> count; j++)
2576+
{
2577+
if (MCU_strcasecmp(t_elements[i], t_set_info -> elements[j] . tag) == 0)
2578+
{
2579+
t_value |= 1 << t_set_info -> elements[j] . bit;
2580+
break;
2581+
}
2582+
}
2583+
}
2584+
2585+
MCCStringArrayFree(t_elements, t_element_count);
2586+
((void(*)(MCExecContext&, MCObjectPtr, unsigned int))t_info -> setter)(ctxt, t_object, t_value);
2587+
}
2588+
break;
25662589

25672590
case kMCPropertyTypeCustom:
25682591
{

engine/src/property.cpp

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3185,8 +3185,23 @@ Exec_stat MCProperty::set_global_property(MCExecPoint& ep)
31853185
break;
31863186

31873187
case kMCPropertyTypeSet:
3188-
ctxt . Unimplemented();
3189-
break;
3188+
{
3189+
MCExecSetTypeInfo *t_set_info;
3190+
t_set_info = (MCExecSetTypeInfo *)(t_info -> type_info);
3191+
3192+
intset_t t_value = 0;
3193+
char **t_elements;
3194+
uindex_t t_element_count;
3195+
MCCStringSplit(ep . getcstring(), ',', t_elements, t_element_count);
3196+
3197+
for (uindex_t i = 0; i < t_element_count; i++)
3198+
for (uindex_t j = 0; j < t_set_info -> count; j++)
3199+
if (MCU_strcasecmp(t_elements[i], t_set_info -> elements[j] . tag) == 0)
3200+
t_value |= 1 << t_set_info -> elements[j] . bit;
3201+
MCCStringArrayFree(t_elements, t_element_count);
3202+
((void(*)(MCExecContext&, unsigned int))t_info -> setter)(ctxt, t_value);
3203+
}
3204+
break;
31903205

31913206
case kMCPropertyTypeCustom:
31923207
{

0 commit comments

Comments
 (0)