Skip to content

Commit

Permalink
[iOS] fix weexsdk compile error
Browse files Browse the repository at this point in the history
  • Loading branch information
jianhan-he committed Nov 13, 2018
1 parent 9a40175 commit 724bcf5
Show file tree
Hide file tree
Showing 11 changed files with 126 additions and 29 deletions.
98 changes: 98 additions & 0 deletions ios/sdk/WeexSDK.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ios/sdk/WeexSDK/Sources/Bridge/WXCoreBridge.mm
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,7 @@ + (void)fireEvent:(NSString *)pageId ref:(NSString *)ref event:(NSString *)event
{
NSString *params = [WXUtility JSONString:args];
auto vnode_manager = weex::core::data_render::VNodeRenderManager::GetInstance();
vnode_manager->FireEvent([pageId UTF8String] ? : "", [ref UTF8String] ? : "", [event UTF8String] ? : "", [params UTF8String] ? : "");
vnode_manager->FireEvent([pageId UTF8String] ? : "", [ref UTF8String] ? : "", [event UTF8String] ? : "", [params UTF8String] ? : "", "");
}

+ (void)registerModules:(NSDictionary *)modules {
Expand Down
28 changes: 13 additions & 15 deletions ios/sdk/WeexSDK/Sources/Utility/WXConvertUtility.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,33 +29,31 @@
#define NSSTRING(cstr) ((__bridge_transfer NSString*)(CFStringCreateWithCString(NULL, (const char *)(cstr), kCFStringEncodingUTF8)))
#define NSSTRING_NO_COPY(cstr) ((__bridge_transfer NSString*)(CFStringCreateWithCStringNoCopy(NULL, (const char *)(cstr), kCFStringEncodingUTF8, kCFAllocatorNull)))

id GenValue(weex::core::data_render::Value* value);
id _Nonnull GenValue(weex::core::data_render::Value* _Nonnull value);

NSString* TO_JSON(id object);
NSString* _Nullable TO_JSON(id _Nullable object);

id TO_OBJECT(NSString* s);
id _Nonnull TO_OBJECT(NSString* _Nonnull s);

NSMutableDictionary* NSDICTIONARY(std::map<std::string, std::string>* map);
NSMutableDictionary* _Nonnull NSDICTIONARY(std::map<std::string, std::string>* _Nullable map);

NSMutableDictionary* NSDICTIONARY(std::unordered_map<std::string, std::string>* map);
NSMutableDictionary* _Nonnull NSDICTIONARY(std::unordered_map<std::string, std::string>* _Nullable map);

NSMutableDictionary* NSDICTIONARY(std::vector<std::pair<std::string, std::string>>* vec);
NSMutableDictionary* _Nonnull NSDICTIONARY(std::vector<std::pair<std::string, std::string>>* _Nullable vec);

NSMutableDictionary* NSDICTIONARY(const std::unordered_map<std::string, weex::core::data_render::VComponent::VNodeRefs>& ref_map);
NSMutableDictionary* _Nonnull NSDICTIONARY(const std::unordered_map<std::string, weex::core::data_render::VComponent::VNodeRefs>& ref_map);

NSMutableDictionary* NSDICTIONARY(weex::core::data_render::Table* table);
NSMutableDictionary* _Nonnull NSDICTIONARY(weex::core::data_render::Table* _Nullable table);

NSMutableArray* NSARRAY(std::set<std::string>* set);
NSMutableArray* _Nonnull NSARRAY(std::set<std::string>* _Nullable set);

NSMutableArray* NSARRAY(weex::core::data_render::Array* array);
NSMutableArray* _Nonnull NSARRAY(weex::core::data_render::Array* _Nullable array);

NSMutableArray* NSARRAY(std::vector<std::unordered_map<std::string, std::string>> refs);
NSMutableArray* _Nonnull NSARRAY(std::vector<std::unordered_map<std::string, std::string>> refs);

NSMutableArray* NSARRAY(const std::vector<weex::core::data_render::Value>& params);
NSMutableArray* _Nonnull NSARRAY(const std::vector<weex::core::data_render::Value>& params);

id GenValue(weex::core::data_render::Value* value);

void ConvertToCString(id _Nonnull obj, void (^callback)(const char*));
void ConvertToCString(id _Nonnull obj, void (^ _Nonnull callback)(const char* _Nullable));

#endif

Expand Down
6 changes: 1 addition & 5 deletions ios/sdk/WeexSDK/Sources/Utility/WXConvertUtility.mm
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,6 @@ id TO_OBJECT(NSString* s)

id GenValue(weex::core::data_render::Value* value)
{
if (!value) {
return nil;
}

switch (value->type) {
case weex::core::data_render::Value::Type::ARRAY:
return NSARRAY( weex::core::data_render::ValueTo<weex::core::data_render::Array>(value));
Expand All @@ -228,7 +224,7 @@ id GenValue(weex::core::data_render::Value* value)
case weex::core::data_render::Value::Type::BOOL:
return [NSNumber numberWithBool:value->b];
default:
return nil;
return [NSNull null];
}
}

Expand Down
1 change: 1 addition & 0 deletions ios/sdk/WeexSDK/Sources/WeexSDK.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
#import "WXDisplayLinkManager.h"
#import "WXDefine.h"
#import "WXDebugTool.h"
#import "WXConvertUtility.h"
#import "WXConvert.h"
#import "WXConfigCenterProtocol.h"
#import "WXComponentManager.h"
Expand Down
4 changes: 3 additions & 1 deletion weex_core/Source/base/string_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ inline static std::string to_utf8(uint16_t* utf16, size_t length) {
return output;
}

#ifdef OS_ANDROID
static std::u16string to_utf16(char* utf8, size_t length) {
std::u16string dest_str;
dest_str.resize(length);
Expand All @@ -97,7 +98,7 @@ static std::u16string to_utf16(char* utf8, size_t length) {

for (int32_t i = 0; i < length;) {
int32_t code_point;
CBU8_NEXT(utf8, i, length, code_point);
CBU8_NEXT(utf8, i, static_cast<int32_t>(length), code_point);

if (!IsValidCodepoint(code_point)) {
success = false;
Expand All @@ -113,6 +114,7 @@ static std::u16string to_utf16(char* utf8, size_t length) {
dest_str.shrink_to_fit();
return dest_str;
}
#endif

} // namespace base
} // namespace weex
Expand Down
2 changes: 1 addition & 1 deletion weex_core/Source/core/data_render/object.h
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ inline void ArrayCopy(Value &src, Value &dest) {
ArrayCopyFrom(src, dest, 0, 0);
}

static void TableCopy(Value &src, Value &dest) {
inline void TableCopy(Value &src, Value &dest) {
if (IsNil(&src)) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,18 @@
namespace core {
namespace data_render {

void VNodeOnEventListener::OnEvent(VNode* node, const std::string& event,
const std::string& json_args,
const VNode::Params& param_list) {
void VNodeOnEventListener::OnEvent(VNode *node, const std::string &event,
const std::string &json_args, const std::string dom_changes,
const VNode::Params &params)
{
std::string page_id = node->component()->exec_state()->context()->page_id();
NSString *instanceId = NSSTRING(page_id.c_str());
WXSDKInstance *instance = [WXSDKManager instanceForID:instanceId];
if (!instance) {
return;
}
node->render_object_ref();
[[WXSDKManager bridgeMgr] callJSMethod:@"callJS" args:@[instanceId, @[@{@"method":@"fireEvent", @"args":@[NSSTRING(node->render_object_ref().c_str()), NSSTRING(event.c_str()), [WXUtility objectFromJSON:NSSTRING(json_args.c_str())], @{@"params": NSARRAY(param_list)}]}]]];
[[WXSDKManager bridgeMgr] callJSMethod:@"callJS" args:@[instanceId, @[@{@"method":@"fireEvent", @"args":@[NSSTRING(node->render_object_ref().c_str()), NSSTRING(event.c_str()), [WXUtility objectFromJSON:NSSTRING(json_args.c_str())], @{@"params": NSARRAY(params)}]}]]];
}

} // namespace data_render
Expand Down
2 changes: 1 addition & 1 deletion weex_core/Source/core/data_render/vnode/vcomponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class VComponent : public VNode {
typedef std::vector<VNodeRef> VNodeRefs;
class LifecycleListener {
public:
~LifecycleListener() {}
virtual ~LifecycleListener() {}
virtual void OnCreated(
VComponent* component, Table* data, Table* props,
const std::unordered_map<std::string, VNodeRefs>& ref_map) = 0;
Expand Down
2 changes: 1 addition & 1 deletion weex_core/Source/core/data_render/vnode/vnode.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class VNode {

class OnEventListener {
public:
~OnEventListener() {}
virtual ~OnEventListener() {}
virtual void OnEvent(VNode *node, const std::string &event,
const std::string &json_args,
const std::string dom_changes,
Expand Down
1 change: 1 addition & 0 deletions weex_core/Source/core/network/request_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ namespace data_render {

class RequestHandler {
public:
virtual ~RequestHandler() {}
virtual void Send(const char* url, std::function<void(const char*)> callback) = 0;
};

Expand Down

0 comments on commit 724bcf5

Please sign in to comment.