青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

隨筆-341  評論-2670  文章-0  trackbacks-0
    從pdb讀取類聲明花了很久,從類聲明產生反射和dll接口花的時間更久啊,很多細節問題需要解決。文章的代碼已經保存在了Vczh Library++3.0(\Tools\Release\SideProjects\GacUI\GacUI.sln)。

    反射和dll接口的工作進行了一半。現在把類、函數、屬性和各種類型都聲稱了出來,但是還欠缺函數的實現。反射使用了lazy的做法,當訪問到一個Type的成員的時候,才會對Type進行初始化。不過初始化的內容也很簡單,只是把一些對方放倒一個列表里面,從而當你想知道一個Type有哪些屬性和函數什么的可以很快查出來。dll的接口也差不多。現在分別展示反射和dll接口的代碼。首先是反射的:

    下面是GuiBoundsComposition類型的反射。我們可以看到gacui_tpimp_GuiBoundsComposition繼承自了TypeDescriptor。當我們調用GetTypeProvider->FindType(L"GuiBoundsComposition")->GetTypeDescriptor()的時候,就會返回下面的這個對象。
  1 class gacui_tpimp_GuiBoundsComposition : public TypeDescriptor
  2 {
  3 protected:
  4 void FillTypeContent()
  5 {
  6     AddBaseType((gacui_tpimp_type_cache_table.cache_GuiGraphicsSite));
  7     AddConstructor(
  8         (new MethodDescriptor(L"GuiBoundsComposition", IMemberDescriptor::Normal))
  9         ->ReturnType((gacui_tpimp_type_cache_table.cache_GuiBoundsComposition)->GetPointerType())
 10         ->Handler(MethodDescriptor::HandlerFuncType(&gacui_tpimp_GuiBoundsComposition::method_handler_GuiBoundsComposition_0))
 11     );
 12     AddMethod(
 13         (new MethodDescriptor(L"GetAffectionFromParent", IMemberDescriptor::Virtual))
 14         ->ReturnType((gacui_tpimp_type_cache_table.cache_GuiGraphicsComposition_member_ParentSizeAffection))
 15         ->Handler(MethodDescriptor::HandlerFuncType(&gacui_tpimp_GuiBoundsComposition::method_handler_GetAffectionFromParent_1))
 16     );
 17     AddMethod(
 18         (new MethodDescriptor(L"GetPreferredBounds", IMemberDescriptor::Virtual))
 19         ->ReturnType((gacui_tpimp_type_cache_table.cache_Rect))
 20         ->Handler(MethodDescriptor::HandlerFuncType(&gacui_tpimp_GuiBoundsComposition::method_handler_GetPreferredBounds_2))
 21     );
 22     AddMethod(
 23         (new MethodDescriptor(L"GetBounds", IMemberDescriptor::Virtual))
 24         ->ReturnType((gacui_tpimp_type_cache_table.cache_Rect))
 25         ->Handler(MethodDescriptor::HandlerFuncType(&gacui_tpimp_GuiBoundsComposition::method_handler_GetBounds_3))
 26     );
 27     AddMethod(
 28         (new MethodDescriptor(L"ClearAlignmentToParent", IMemberDescriptor::Normal))
 29         ->ReturnType((gacui_tpimp_type_cache_table.primary_Void))
 30         ->Handler(MethodDescriptor::HandlerFuncType(&gacui_tpimp_GuiBoundsComposition::method_handler_ClearAlignmentToParent_4))
 31     );
 32     AddMethod(
 33         (new MethodDescriptor(L"IsAlignedToParent", IMemberDescriptor::Normal))
 34         ->ReturnType((gacui_tpimp_type_cache_table.primary_Bool))
 35         ->Handler(MethodDescriptor::HandlerFuncType(&gacui_tpimp_GuiBoundsComposition::method_handler_IsAlignedToParent_5))
 36     );
 37     AddMethod(
 38         (new MethodDescriptor(L"operator=", IMemberDescriptor::Normal))
 39         ->ReturnType((gacui_tpimp_type_cache_table.cache_GuiBoundsComposition)->GetReferenceType())
 40         ->Parameter(L"value", (gacui_tpimp_type_cache_table.cache_GuiBoundsComposition)->GetConstReferenceType())
 41         ->Handler(MethodDescriptor::HandlerFuncType(&gacui_tpimp_GuiBoundsComposition::method_handler_operator_assign_6))
 42     );
 43     AddMethod(
 44         (new MethodDescriptor(L"SetBounds", IMemberDescriptor::Normal))
 45         ->ReturnType((gacui_tpimp_type_cache_table.primary_Void))
 46         ->Parameter(L"value", (gacui_tpimp_type_cache_table.cache_Rect))
 47         ->Handler(MethodDescriptor::HandlerFuncType(&gacui_tpimp_GuiBoundsComposition::method_handler_SetBounds_7))
 48     );
 49     AddProperty(
 50         (new PropertyDescriptor(L"AlignmentToParent", IMemberDescriptor::Normal))
 51         ->PropertyType((gacui_tpimp_type_cache_table.cache_Margin))
 52         ->Getter(
 53             (new MethodDescriptor(L"GetAlignmentToParent", IMemberDescriptor::Normal))
 54             ->ReturnType((gacui_tpimp_type_cache_table.cache_Margin))
 55             ->Handler(MethodDescriptor::HandlerFuncType(&gacui_tpimp_GuiBoundsComposition::method_handler_GetAlignmentToParent_8))
 56         )
 57         ->Setter(
 58             (new MethodDescriptor(L"SetAlignmentToParent", IMemberDescriptor::Normal))
 59             ->ReturnType((gacui_tpimp_type_cache_table.primary_Void))
 60             ->Parameter(L"value", (gacui_tpimp_type_cache_table.cache_Margin))
 61             ->Handler(MethodDescriptor::HandlerFuncType(&gacui_tpimp_GuiBoundsComposition::method_handler_SetAlignmentToParent_9))
 62         )
 63     );
 64     AddProperty(
 65         (new PropertyDescriptor(L"BoundsChanged", IMemberDescriptor::Normal))
 66         ->PropertyType((gacui_tpimp_type_cache_table.cache_GuiGraphicsEvent_of_GuiEventArgs))
 67         ->Getter(
 68             (new MethodDescriptor(L"get_BoundsChanged", IMemberDescriptor::Normal))
 69             ->ReturnType((gacui_tpimp_type_cache_table.cache_GuiGraphicsEvent_of_GuiEventArgs))
 70             ->Handler(MethodDescriptor::HandlerFuncType(&gacui_tpimp_GuiBoundsComposition::method_handler_get_BoundsChanged_10))
 71         )
 72         ->Setter(
 73             (new MethodDescriptor(L"set_BoundsChanged", IMemberDescriptor::Normal))
 74             ->ReturnType((gacui_tpimp_type_cache_table.primary_Void))
 75             ->Parameter(L"value", (gacui_tpimp_type_cache_table.cache_GuiGraphicsEvent_of_GuiEventArgs))
 76             ->Handler(MethodDescriptor::HandlerFuncType(&gacui_tpimp_GuiBoundsComposition::method_handler_set_BoundsChanged_11))
 77         )
 78     );
 79 }
 80             
 81 private:
 82                 
 83 static DescriptableValue method_handler_GuiBoundsComposition_0(const DescriptableValue& thisObject, const collections::IReadonlyList<DescriptableValue>& parameters)
 84 {
 85     throw 0;
 86 }
 87                 
 88 static DescriptableValue method_handler_GetAffectionFromParent_1(const DescriptableValue& thisObject, const collections::IReadonlyList<DescriptableValue>& parameters)
 89 {
 90     throw 0;
 91 }
 92                 
 93 static DescriptableValue method_handler_GetPreferredBounds_2(const DescriptableValue& thisObject, const collections::IReadonlyList<DescriptableValue>& parameters)
 94 {
 95     throw 0;
 96 }
 97                 
 98 static DescriptableValue method_handler_GetBounds_3(const DescriptableValue& thisObject, const collections::IReadonlyList<DescriptableValue>& parameters)
 99 {
100     throw 0;
101 }
102                 
103 static DescriptableValue method_handler_ClearAlignmentToParent_4(const DescriptableValue& thisObject, const collections::IReadonlyList<DescriptableValue>& parameters)
104 {
105     throw 0;
106 }
107                 
108 static DescriptableValue method_handler_IsAlignedToParent_5(const DescriptableValue& thisObject, const collections::IReadonlyList<DescriptableValue>& parameters)
109 {
110     throw 0;
111 }
112                 
113 static DescriptableValue method_handler_operator_assign_6(const DescriptableValue& thisObject, const collections::IReadonlyList<DescriptableValue>& parameters)
114 {
115     throw 0;
116 }
117                 
118 static DescriptableValue method_handler_SetBounds_7(const DescriptableValue& thisObject, const collections::IReadonlyList<DescriptableValue>& parameters)
119 {
120     throw 0;
121 }
122                 
123 static DescriptableValue method_handler_GetAlignmentToParent_8(const DescriptableValue& thisObject, const collections::IReadonlyList<DescriptableValue>& parameters)
124 {
125     throw 0;
126 }
127                 
128 static DescriptableValue method_handler_SetAlignmentToParent_9(const DescriptableValue& thisObject, const collections::IReadonlyList<DescriptableValue>& parameters)
129 {
130     throw 0;
131 }
132                 
133 static DescriptableValue method_handler_get_BoundsChanged_10(const DescriptableValue& thisObject, const collections::IReadonlyList<DescriptableValue>& parameters)
134 {
135     throw 0;
136 }
137                 
138 static DescriptableValue method_handler_set_BoundsChanged_11(const DescriptableValue& thisObject, const collections::IReadonlyList<DescriptableValue>& parameters)
139 {
140     throw 0;
141 }
142             
143 public:
144 };

    如果反射出來的函數不能被調用那自然是沒有意義的,所以AddMethod的時候會提供一個handler,而handler就是下面的靜態成員函數了。靜態成員函數的實現就是從thisObject拿到GuiBoundsComposition*之后,去調用對應的函數。這個部分是可以自動生成的,只是現在還沒寫完。

    反射只是一部分,dll的接口也要生成,因為GacUI的實現使用了很多模板和自定義異常,而模板和異常跨越dll邊界是很危險的,所以需要用自動生成的代碼來把這些東西隔離開(包括一場),從而實現安全調用。下面就是自動生成的dll接口代碼,而同樣,函數也暫時沒有實現的內容:
 1 /***********************************************************************
 2 GuiBoundsComposition
 3 ***********************************************************************/
 4 
 5     class GACUI_API GuiBoundsComposition : public GuiGraphicsSite
 6     {
 7     public:
 8     
 9     public:
10         
11         static rptr<GuiBoundsComposition> Create();
12         
13         GuiGraphicsComposition :: ParentSizeAffection GetAffectionFromParent();
14         Rect GetPreferredBounds();
15         Rect GetBounds();
16         void ClearAlignmentToParent();
17         bool IsAlignedToParent();
18         rptr<GuiBoundsComposition> operator=(rptr<GuiBoundsComposition> value);
19         void SetBounds(Rect value);
20         
21         Margin GetAlignmentToParent();
22         void SetAlignmentToParent(Margin value);
23         GuiGraphicsEvent_of_GuiEventArgs on_BoundsChanged();
24         
25     };
26 
27 /***********************************************************************
28 GuiBoundsComposition
29 ***********************************************************************/
30 
31     rptr<GuiBoundsComposition> GuiBoundsComposition::Create()
32     {
33         throw 0;
34     }
35     
36     GuiGraphicsComposition :: ParentSizeAffection GuiBoundsComposition::GetAffectionFromParent()
37     {
38         throw 0;
39     }
40     
41     Rect GuiBoundsComposition::GetPreferredBounds()
42     {
43         throw 0;
44     }
45     
46     Rect GuiBoundsComposition::GetBounds()
47     {
48         throw 0;
49     }
50     
51     void GuiBoundsComposition::ClearAlignmentToParent()
52     {
53         throw 0;
54     }
55     
56     bool GuiBoundsComposition::IsAlignedToParent()
57     {
58         throw 0;
59     }
60     
61     rptr<GuiBoundsComposition> GuiBoundsComposition::operator=(rptr<GuiBoundsComposition> value)
62     {
63         throw 0;
64     }
65     
66     void GuiBoundsComposition::SetBounds(Rect value)
67     {
68         throw 0;
69     }
70     
71     Margin GuiBoundsComposition::GetAlignmentToParent()
72     {
73         throw 0;
74     }
75     void GuiBoundsComposition::SetAlignmentToParent(Margin value)
76     {
77         throw 0;
78     }
79     
80     GuiGraphicsEvent_of_GuiEventArgs GuiBoundsComposition::on_BoundsChanged()
81     {
82         throw 0;
83     }

    dll接口的部分生成比較簡單,因為類似int這樣的類型可以直接使用,而不像反射一樣還得給一個對象來告訴你這個是int。

    之所要這兩部分,是因為GacUI不僅允許用戶直接操作某個控件,也需要同時允許界面使用XML描述,或者以后對腳本的支持。C++訪問控件不需要反射,而XML和腳本則需要。XML描述界面是很重要的,因為這不僅可以用來支持皮膚、資源等高級抽象,還可以圍繞XML開發一個跟Blend Expression(當然不可能有那么高級= =b)的GUI編輯器。

    接下來會繼續給這些函數生成實現。這部分完成之后,GacUI就真正可以通過dll的方法來運行了。一旦把功能都坐進了dll,那么實現類似visual studio那樣的可以把界面插件分散在各個dll里面的編輯器框架,也消除了技術上的困難。
posted on 2012-02-21 10:33 陳梓瀚(vczh) 閱讀(3581) 評論(3)  編輯 收藏 引用 所屬分類: GacUI

評論:
# re: GacUI從pdb生成反射和dll接口首戰告捷 2012-02-22 19:28 | marvin
看得出,你很用心

C++語言加反射很累。記得有一個庫
http://acdk.sourceforge.net/

  回復  更多評論
  
# re: GacUI從pdb生成反射和dll接口首戰告捷 2012-02-22 21:17 | phoenixbing
如意金箍棒。重三萬六千斤。我頂。  回復  更多評論
  
青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            欧美一级久久| 久久久久久久97| 亚洲国产精品999| 亚洲大胆美女视频| 国产精品视频精品| 亚洲一区二区三区四区在线观看 | 亚洲第一中文字幕| 亚洲午夜视频在线| 久久这里只有| 亚洲欧美在线磁力| 美女国产一区| 亚洲欧美中文另类| 国产精品丝袜91| 亚洲伦理精品| 激情综合色丁香一区二区| 美女免费视频一区| 久久久久九九九| 欧美一区二区三区在线视频| 欧美在线首页| 亚洲韩国青草视频| 欧美性事免费在线观看| 久久天堂国产精品| 国产欧美日韩激情| 久久精品国产亚洲精品| 亚洲一区尤物| 欧美激情一区二区三区在线视频 | 米奇777在线欧美播放| 亚洲综合日韩在线| 国内外成人免费视频| 久久综合久久久| 久久亚洲午夜电影| 久久久国产一区二区| 欧美激情第二页| 欧美一级视频免费在线观看| 欧美日韩在线视频首页| 久久99伊人| 久久国产毛片| 在线成人免费视频| 亚洲欧美日韩在线一区| 国产手机视频一区二区| 国产精品久久久久7777婷婷| 日韩一级在线观看| 亚洲乱亚洲高清| 伊人夜夜躁av伊人久久| 黄色成人在线网站| 欧美成人首页| 欧美日韩成人综合| 国产精品美女在线| 亚洲欧美激情诱惑| 欧美18av| 最新亚洲视频| 亚洲天天影视| 欧美亚洲免费在线| 久久黄色网页| 久久大综合网| 欧美一区二区三区四区在线观看地址| 欧美一区二区视频免费观看| 亚洲图片欧洲图片日韩av| 免费日韩精品中文字幕视频在线| 亚洲一区二区成人在线观看| 免费观看久久久4p| 欧美丰满少妇xxxbbb| 亚洲一级二级在线| 亚洲欧洲综合另类在线| 国产亚洲在线| 黄色成人免费网站| 日韩一二在线观看| 亚洲破处大片| 亚洲视频欧美视频| 欧美有码视频| 亚洲美女在线一区| 在线视频欧美一区| 两个人的视频www国产精品| 老司机一区二区三区| 99热免费精品| 亚洲男人的天堂在线| 欧美专区在线观看一区| 国内久久视频| 极品尤物av久久免费看| 日韩一级不卡| 久久久xxx| 一区二区三区视频免费在线观看| 久久女同精品一区二区| 欧美大色视频| 性欧美暴力猛交另类hd| 欧美黄免费看| 韩国一区电影| 在线视频精品一| 久久久国产一区二区三区| 欧美在线视频全部完| 久久夜色精品亚洲噜噜国产mv| 国产一区二区三区黄视频| 亚洲欧美日韩在线观看a三区| 亚洲视频在线观看一区| 日韩图片一区| 性18欧美另类| 国精产品99永久一区一区| 日韩一区二区久久| 噜噜噜在线观看免费视频日韩| 亚洲国产一区在线| 亚洲一级黄色片| 国产视频精品免费播放| 亚洲国产第一| 夜夜嗨av一区二区三区免费区| 欧美性一二三区| 在线一区欧美| 91久久精品国产91久久性色| 一区二区三区日韩欧美精品| 欧美另类一区| 亚洲——在线| 一区二区精品在线| 国产视频久久久久| 免费观看一级特黄欧美大片| 欧美日韩精品在线| 欧美 日韩 国产 一区| 亚洲欧美日韩精品久久亚洲区 | 欧美中文在线观看| 亚洲国产精品va在线看黑人动漫 | 欧美日韩一区二区免费在线观看| 欧美激情亚洲激情| 久久免费视频在线| 亚洲手机视频| 国产女主播一区| 裸体素人女欧美日韩| 欧美日韩国产欧| 免费观看亚洲视频大全| 国产精品久久国产三级国电话系列| 欧美福利网址| 国产网站欧美日韩免费精品在线观看| 亚洲精选视频在线| 亚洲人成网站777色婷婷| 午夜精品视频在线| 亚洲欧美日韩国产| 国产精品家庭影院| 一区二区三区精品| 亚洲综合久久久久| 国产精品美女久久| 亚洲自拍偷拍麻豆| 久久电影一区| 国产亚洲欧美日韩精品| 午夜精品久久久久久久| 欧美一二三区在线观看| 国产精品区二区三区日本| 亚洲视频免费在线| 欧美一级艳片视频免费观看| 国产精品美女久久久久久免费 | 99精品视频免费在线观看| 裸体一区二区| 欧美a级片网站| 红桃av永久久久| 欧美在线亚洲一区| 免费一级欧美片在线播放| 亚洲国产视频一区| 欧美护士18xxxxhd| 亚洲精品视频在线观看网站| 99re视频这里只有精品| 欧美日韩国产精品 | 午夜在线电影亚洲一区| 欧美专区日韩视频| 国产一区二区三区四区在线观看| 欧美在线视频一区二区三区| 久久在线免费观看| 亚洲激情综合| 欧美日韩一区在线观看| 亚洲一区二区高清| 久久嫩草精品久久久精品一| 亚洲国产精品123| 欧美日韩一区精品| 久久久久国产一区二区三区| 亚洲高清在线视频| 一本久道久久综合狠狠爱| 国产精品s色| 久久久水蜜桃| 亚洲美女黄网| 久久亚洲不卡| 在线亚洲国产精品网站| 国产真实乱子伦精品视频| 欧美激情一区二区三级高清视频 | 欧美激情国产日韩精品一区18| 久久精品二区亚洲w码| 亚洲成在人线av| 夜夜嗨av色一区二区不卡| 国产精品一区二区黑丝| 久久精品日产第一区二区三区| 亚洲欧洲精品一区二区三区 | 欧美日本精品在线| 亚洲欧美日韩天堂| 亚洲国产视频一区| 久久久噜噜噜久久久| 亚洲免费电影在线| 国产在线视频欧美一区二区三区| 欧美日韩黄色一区二区| 久久九九99| 亚洲午夜精品一区二区| 亚洲国产成人av| 久久久久久网址| 亚洲在线成人| 日韩一区二区精品在线观看| 精品电影在线观看| 国产一区二区无遮挡|